ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-07-31 04:29:18
Exec Total Coverage
Lines: 9200 12204 75.4%
Functions: 378 436 86.7%
Branches: 7300 12920 56.5%

Line Branch Exec Source
1 #include "base/handles.h"
2 #include "base/zdefs.h"
3 #include <cstring>
4 #include <optional>
5 #include <stdio.h>
6 #include "base/combo.h"
7 #include "base/general.h"
8 #include "base/zc_alleg.h"
9 #include "zc/guys.h"
10 #include "zc/replay.h"
11 #include "zc/zc_ffc.h"
12 #include "zc/zc_subscr.h"
13 #include "zc/zelda.h"
14 #include "base/zsys.h"
15 #include "base/msgstr.h"
16 #include "zc/maps.h"
17 #include "zc/hero.h"
18 #include "subscr.h"
19 #include "zc/ffscript.h"
20 #include "gamedata.h"
21 #include "defdata.h"
22 #include "zscriptversion.h"
23 #include "particles.h"
24 #include "base/zc_math.h"
25 #include "slopes.h"
26 #include "base/qrs.h"
27 #include "base/dmap.h"
28 #include "base/mapscr.h"
29 #include "base/misctypes.h"
30 #include "base/initdata.h"
31 #include "zc/combos.h"
32 #include "iter.h"
33
34 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
35
36 int32_t repaircharge=0;
37 bool adjustmagic=false;
38 bool learnslash=false;
39 int32_t wallm_load_clk=0;
40 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
41 int32_t vhead=0;
42
43 char *guy_string[eMAXGUYS];
44
45 void playLevelMusic();
46
47 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
48 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
49
50 1113221 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
51 {
52 1113221 int32_t c = coord.getInt();
53
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1112944 times.
1113221 if(nearest_half)
54 {
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1112944 times.
1112944 if (c < 0)
56 c -= val / 2;
57 1112944 else c += (val/2);
58 1112944 }
59 1113221 c -= c % val;
60 1113221 coord = c;
61 1113221 }
62
63 38561765 static bool OUTOFBOUNDS(int32_t id, int32_t x, int32_t y)
64 {
65
4/4
✓ Branch 0 taken 38045159 times.
✓ Branch 1 taken 516606 times.
✓ Branch 2 taken 1215 times.
✓ Branch 3 taken 38560550 times.
38561765 if (y > world_h + (isSideViewGravity() && canfall(id) ? 16 : 176)) return true;
66
2/2
✓ Branch 0 taken 30320 times.
✓ Branch 1 taken 38530230 times.
38560550 if (y < -176) return true;
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38530230 times.
38530230 if (x < -256) return true;
68
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 38530164 times.
38530230 if (x > world_w+256) return true;
69 38530164 return false;
70 38561765 }
71
72 bool NEWOUTOFBOUNDS(int32_t x, int32_t y, int32_t z)
73 {
74 return
75 (
76 (y > FFCore.enemy_removal_point[spriteremovalY2])
77 || (y < FFCore.enemy_removal_point[spriteremovalY1])
78 || (x < FFCore.enemy_removal_point[spriteremovalX1])
79 || (x > FFCore.enemy_removal_point[spriteremovalX2])
80 || (z < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (z > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 6674 static void position_relative_to_screen(zfix& x, zfix& y, int32_t rx, int32_t ry)
86 {
87 6674 x = rx + (x.getInt()/256)*256;
88 6674 y = ry + (y.getInt()/176)*176;
89 6674 }
90
91 namespace
92 {
93 int32_t trapConstantHorizontalID;
94 int32_t trapConstantVerticalID;
95 int32_t trapLOSHorizontalID;
96 int32_t trapLOSVerticalID;
97 int32_t trapLOS4WayID;
98
99 int32_t cornerTrapID;
100 int32_t centerTrapID;
101
102 int32_t rockID;
103 int32_t zoraID;
104 int32_t statueID;
105 }
106
107 423 void identifyCFEnemies()
108 {
109 423 trapConstantHorizontalID=-1;
110 423 trapConstantVerticalID=-1;
111 423 trapLOSHorizontalID=-1;
112 423 trapLOSVerticalID=-1;
113 423 trapLOS4WayID=-1;
114 423 cornerTrapID=-1;
115 423 centerTrapID=-1;
116 423 rockID=-1;
117 423 zoraID=-1;
118 423 statueID=-1;
119
120
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 423 times.
216999 for(int32_t i=0; i<eMAXGUYS; i++)
121 {
122
3/4
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 216159 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 417 times.
216576 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
123 417 trapLOSHorizontalID=i;
124
4/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 216144 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
125 423 trapLOSVerticalID=i;
126
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 216153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
127 423 trapLOS4WayID=i;
128
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 216153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
129 423 trapConstantHorizontalID=i;
130
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 216153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
131 423 trapConstantVerticalID=i;
132
133
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 216153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
134 423 cornerTrapID=i;
135
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 216153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
136 423 centerTrapID=i;
137
138
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 216153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_rock) && rockID==-1)
139 423 rockID=i;
140
4/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 216130 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 420 times.
216576 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
141 420 zoraID=i;
142
143
4/4
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 216090 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags & guy_fire) && statueID==-1)
144 423 statueID=i;
145 216576 }
146 423 }
147
148 32 int32_t random_layer_enemy(int screen)
149 {
150 32 int32_t cnt=count_layer_enemies(screen);
151 32 mapscr* base_scr = get_scr(screen);
152
153
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
154 {
155 return eNONE;
156 }
157
158 32 int32_t ret=zc_oldrand()%cnt;
159 32 cnt=0;
160
161
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
162 {
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(base_scr->layermap[i]!=0)
164 {
165 32 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
166
167
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
168 {
169
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
170 {
171
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
172 {
173 32 return layerscreen->enemy[j];
174 }
175
176 108 ++cnt;
177 108 }
178 108 }
179 }
180 }
181
182 return eNONE;
183 32 }
184
185 49 int32_t count_layer_enemies(int screen)
186 {
187 49 int32_t cnt=0;
188
189 49 mapscr* base_scr = get_scr(screen);
190
191
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
192 {
193
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if (base_scr->layermap[i])
194 {
195 79 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
196
197
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
198 {
199
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
200 {
201 420 ++cnt;
202 420 }
203 790 }
204 79 }
205 294 }
206
207 49 return cnt;
208 }
209
210 211789 int32_t hero_on_wall()
211 {
212 211789 zfix lx = Hero.getX();
213 211789 zfix ly = Hero.getY();
214
215
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=world_w-64)
216 {
217
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
218
219
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==world_h-48) return down+1;
220 180473 }
221
222
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=world_h-64)
223 {
224
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
225
226
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==world_w-48) return right+1;
227 172303 }
228
229 210948 return 0;
230 211789 }
231
232 806966 bool tooclose(int32_t x,int32_t y,int32_t d)
233 {
234
2/2
✓ Branch 0 taken 600908 times.
✓ Branch 1 taken 206058 times.
806966 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
235 }
236
237 4019514 bool enemy::overpit(enemy *e)
238 {
239 // This function (and shadow_overpit) has been broken since it was written, and only
240 // checked the same diagonal of the hitbox, over and over again. The bug is because both
241 // loops used the same variable name.
242 // Checking literally every pixel seems like overkill, so for now let's continue to
243 // do the single diagonal but just once. That's why the outer loop is commented out.
244
245 // for ( int32_t q = 0; q < hxsz; ++q )
246 {
247
2/2
✓ Branch 0 taken 37189774 times.
✓ Branch 1 taken 4000312 times.
41190086 for ( int32_t q = 0; q < hit_height; ++q )
248 {
249 //check every pixel of the hitbox
250
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 37170572 times.
37189774 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
251 {
252 //if the hitbox is over a pit, we can't land
253 19202 return true;
254 }
255 37170572 }
256 }
257 4000312 return false;
258 4019514 }
259
260 12361497 bool enemy::shadow_overpit(enemy *e)
261 {
262 // for ( int32_t q = 0; q < hxsz; ++q )
263 {
264
2/2
✓ Branch 0 taken 177571650 times.
✓ Branch 1 taken 12335036 times.
189906686 for ( int32_t q = 0; q < hit_height; ++q )
265 {
266 //check every pixel of the hitbox
267
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 177545189 times.
177571650 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
268 {
269 //if the hitbox is over a pit, we can't land
270 26461 return true;
271 }
272 177545189 }
273 }
274 12335036 return false;
275 12361497 }
276
277 // Returns true iff a combo type or flag precludes enemy movement.
278 7438523 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
279 {
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7438523 times.
7438523 if(moveflags & move_ignore_blockflags) return false;
281 7438523 int32_t c = COMBOTYPE(dx,dy);
282
4/4
✓ Branch 0 taken 4895375 times.
✓ Branch 1 taken 2543148 times.
✓ Branch 2 taken 1400387 times.
✓ Branch 3 taken 1142761 times.
9981671 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
283
3/6
✓ Branch 0 taken 2524824 times.
✓ Branch 1 taken 4913699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2524824 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7438523 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
284
5/6
✓ Branch 0 taken 2584226 times.
✓ Branch 1 taken 4854297 times.
✓ Branch 2 taken 2582349 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2582349 times.
✗ Branch 5 not taken.
14877810 return c==cPIT || c==cPITB || c==cPITC ||
285
4/6
✓ Branch 0 taken 2582349 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2582349 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2433745 times.
✓ Branch 5 taken 148604 times.
2582349 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
286 // Block enemies type and block enemies flags
287
2/2
✓ Branch 0 taken 2577073 times.
✓ Branch 1 taken 2428469 times.
148604 combo_class_buf[c].block_enemies&1 ||
288
4/4
✓ Branch 0 taken 2574403 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2574156 times.
✓ Branch 3 taken 247 times.
2577073 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
289
4/4
✓ Branch 0 taken 2573338 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2573272 times.
✓ Branch 3 taken 66 times.
2574156 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
290 // Check for ladder-only combos which aren't dried water
291
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2562646 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5146249 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
292 // Check for drownable water
293
4/4
✓ Branch 0 taken 574658 times.
✓ Branch 1 taken 1998319 times.
✓ Branch 2 taken 2332 times.
✓ Branch 3 taken 572326 times.
2572977 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true, false, false)));
294 2586867 }
295
296 // Returns true iff enemy is floating and blocked by a combo type or flag.
297 8696035 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
298 {
299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8696035 times.
8696035 if(moveflags & move_ignore_blockflags) return false;
300
4/4
✓ Branch 0 taken 6597053 times.
✓ Branch 1 taken 2098982 times.
✓ Branch 2 taken 1750204 times.
✓ Branch 3 taken 348778 times.
10795017 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
301
3/4
✓ Branch 0 taken 6611560 times.
✓ Branch 1 taken 2084475 times.
✓ Branch 2 taken 2084475 times.
✗ Branch 3 not taken.
10780510 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
302
2/2
✓ Branch 0 taken 1201939 times.
✓ Branch 1 taken 7494096 times.
16190131 return ((special==spw_floater)&&
303
2/2
✓ Branch 0 taken 7483953 times.
✓ Branch 1 taken 10143 times.
7494096 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
304
2/2
✓ Branch 0 taken 7483834 times.
✓ Branch 1 taken 119 times.
7483953 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
305
2/2
✓ Branch 0 taken 7483663 times.
✓ Branch 1 taken 171 times.
7483834 (MAPFLAG(dx,dy)==mfNOENEMY)||
306
2/2
✓ Branch 0 taken 7483408 times.
✓ Branch 1 taken 255 times.
7483663 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
307
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6240879 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14962812 (water_blocks && iswaterex_z3(MAPCOMBO(dx, dy), -1, dx,dy, false, false, true)) ||
308
2/2
✓ Branch 0 taken 6231290 times.
✓ Branch 1 taken 1248114 times.
7479404 (pit_blocks && ispitfall(dx,dy))));
309 8696035 }
310 // Returns true iff a combo type or flag precludes enemy movement.
311 282052 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
312 {
313 282052 int32_t c = COMBOTYPE(dx,dy);
314 282052 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
315
2/2
✓ Branch 0 taken 35554 times.
✓ Branch 1 taken 246498 times.
282052 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
316
5/6
✓ Branch 0 taken 282032 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 281915 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 281915 times.
✗ Branch 5 not taken.
1062905 return c==cPIT || c==cPITB || c==cPITC ||
317
4/6
✓ Branch 0 taken 281915 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281915 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250042 times.
✓ Branch 5 taken 31873 times.
281915 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
318 // Block enemies type and block enemies flags
319
2/2
✓ Branch 0 taken 281342 times.
✓ Branch 1 taken 249469 times.
31873 combo_class_buf[c].block_enemies&1 ||
320
4/4
✓ Branch 0 taken 280955 times.
✓ Branch 1 taken 387 times.
✓ Branch 2 taken 280924 times.
✓ Branch 3 taken 31 times.
281342 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
321
4/4
✓ Branch 0 taken 277269 times.
✓ Branch 1 taken 3655 times.
✓ Branch 2 taken 276994 times.
✓ Branch 3 taken 275 times.
280924 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
322 // Check for ladder-only combos which aren't dried water
323
4/4
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 275950 times.
✓ Branch 2 taken 1005 times.
✓ Branch 3 taken 39 times.
553949 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
324 // Check for drownable water
325
4/4
✓ Branch 0 taken 53168 times.
✓ Branch 1 taken 223787 times.
✓ Branch 2 taken 28535 times.
✓ Branch 3 taken 24633 times.
276955 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)));
326 }
327
328 // Returns true iff enemy is floating and blocked by a combo type or flag.
329 139610 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
330 {
331
2/2
✓ Branch 0 taken 137287 times.
✓ Branch 1 taken 2323 times.
139610 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
332 139610 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139610 times.
279220 return ((special==spw_floater)&&
334
2/2
✓ Branch 0 taken 139513 times.
✓ Branch 1 taken 97 times.
139610 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
335
2/2
✓ Branch 0 taken 139508 times.
✓ Branch 1 taken 5 times.
139513 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
336
2/2
✓ Branch 0 taken 139499 times.
✓ Branch 1 taken 9 times.
139508 (MAPFLAG(dx,dy)==mfNOENEMY)||
337
2/2
✓ Branch 0 taken 139470 times.
✓ Branch 1 taken 29 times.
139499 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
338
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 137149 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
278690 (water_blocks && iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)) ||
339
2/2
✓ Branch 0 taken 137149 times.
✓ Branch 1 taken 2071 times.
139220 (pit_blocks && ispitfall(dx,dy))));
340 }
341
342
5/10
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115229 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115229 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115229 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115229 times.
✗ Branch 9 not taken.
230458 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
343 115229 {
344
1/2
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
115229 x=X;
345
1/2
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
115229 y=Y;
346
3/6
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115229 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115229 times.
✗ Branch 5 not taken.
115229 screen_spawned=get_screen_for_world_xy(x.getInt(), y.getInt());
347 115229 id=Id;
348 115229 clk=Clk;
349
1/2
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
115229 floor_y=y;
350 115229 ceiling=false;
351 115229 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
352 115229 grumble = movestatus = posframe = timer = ox = oy = 0;
353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115229 times.
✓ Branch 2 taken 115229 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115229 times.
✗ Branch 5 not taken.
115229 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
354 115229 did_armos=true;
355 115229 script_spawned=false;
356
357 115229 d = guysbuf + (id & 0xFFF);
358 115229 hp = d->hp;
359 115229 starting_hp = hp;
360 // cs = d->cset;
361 //d variables
362
363 115229 flags=d->flags;
364 115229 flags=d->flags;
365 115229 s_tile=d->s_tile; //secondary (additional) tile(s)
366 115229 family=d->family;
367 115229 dcset=d->cset;
368 115229 cs=dcset;
369
2/2
✓ Branch 0 taken 89095 times.
✓ Branch 1 taken 26134 times.
115229 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
370 115229 dp=d->dp;
371 115229 wdp=d->wdp;
372 115229 wpn=d->weapon;
373 115229 wpnsprite = d-> wpnsprite; //2.6 -Z
374 115229 rate=d->rate;
375 115229 hrate=d->hrate;
376
1/2
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
115229 dstep=d->step;
377 115229 homing=d->homing;
378 115229 dmisc1=d->attributes[0];
379 115229 dmisc2=d->attributes[1];
380 115229 dmisc3=d->attributes[2];
381 115229 dmisc4=d->attributes[3];
382 115229 dmisc5=d->attributes[4];
383 115229 dmisc6=d->attributes[5];
384 115229 dmisc7=d->attributes[6];
385 115229 dmisc8=d->attributes[7];
386 115229 dmisc9=d->attributes[8];
387 115229 dmisc10=d->attributes[9];
388 115229 dmisc11=d->attributes[10];
389 115229 dmisc12=d->attributes[11];
390 115229 dmisc13=d->attributes[12];
391 115229 dmisc14=d->attributes[13];
392 115229 dmisc15=d->attributes[14];
393 115229 dmisc16=d->attributes[15];
394 115229 dmisc17=d->attributes[16];
395 115229 dmisc18=d->attributes[17];
396 115229 dmisc19=d->attributes[18];
397 115229 dmisc20=d->attributes[19];
398 115229 dmisc21=d->attributes[20];
399 115229 dmisc22=d->attributes[21];
400 115229 dmisc23=d->attributes[22];
401 115229 dmisc24=d->attributes[23];
402 115229 dmisc25=d->attributes[24];
403 115229 dmisc26=d->attributes[25];
404 115229 dmisc27=d->attributes[26];
405 115229 dmisc28=d->attributes[27];
406 115229 dmisc29=d->attributes[28];
407 115229 dmisc30=d->attributes[29];
408 115229 dmisc31=d->attributes[30];
409 115229 dmisc32=d->attributes[31];
410
2/2
✓ Branch 0 taken 4274 times.
✓ Branch 1 taken 110955 times.
115229 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
411 {
412 110955 dmisc31 = dmisc32;
413 110955 dmisc32 = 0;
414 110955 }
415 115229 spr_shadow=d->spr_shadow;
416 115229 spr_death=d->spr_death;
417 115229 spr_spawn=d->spr_spawn;
418
419
2/2
✓ Branch 0 taken 4724389 times.
✓ Branch 1 taken 115229 times.
4839618 for(int32_t i=0; i<edefLAST255; i++)
420 4724389 defense[i]=d->defense[i];
421
422 115229 bgsfx=d->bgsfx;
423 115229 hitsfx=d->hitsfx;
424 115229 deadsfx=d->deadsfx;
425 115229 bosspal=d->bosspal;
426
427 115229 frozentile = d->frozentile;
428
429 115229 frozencset = d->frozencset;
430 115229 frozenclock = 0;
431
2/2
✓ Branch 0 taken 1152290 times.
✓ Branch 1 taken 115229 times.
1267519 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
432
433
2/2
✓ Branch 0 taken 1958893 times.
✓ Branch 1 taken 115229 times.
2074122 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
434 //firesfx = 0; //t.b.a -Z
435 115229 isCore = true; //t.b.a
436 115229 parentCore = 0; //t.b.a
437
438 115229 firesfx = d->firesfx;
439
2/2
✓ Branch 0 taken 3687328 times.
✓ Branch 1 taken 115229 times.
3802557 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
440
2/2
✓ Branch 0 taken 3687328 times.
✓ Branch 1 taken 115229 times.
3802557 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
441
442 115229 script = d->script;
443
444
2/2
✓ Branch 0 taken 921832 times.
✓ Branch 1 taken 115229 times.
1037061 for ( int32_t q = 0; q < 8; q++ )
445 {
446 921832 initD[q] = d->initD[q];
447 921832 }
448
449 115229 stickclk = 0;
450 115229 submerged = false;
451 115229 didScriptThisFrame = false;
452 115229 ffcactivated = std::nullopt;
453 115229 hitdir = -1;
454 115229 editorflags = d->editorflags; //set by Enemy Editor
455 //Set the drawing flag for this sprite.
456
1/2
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
115229 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
457
458
459
2/2
✓ Branch 0 taken 8920 times.
✓ Branch 1 taken 106309 times.
115229 if(bosspal>-1)
460 {
461
1/2
✓ Branch 0 taken 8920 times.
✗ Branch 1 not taken.
8920 loadpalset(csBOSS,pSprite(bosspal));
462 8920 }
463
464
2/2
✓ Branch 0 taken 50320 times.
✓ Branch 1 taken 64909 times.
115229 if(bgsfx>-1)
465 {
466
1/2
✓ Branch 0 taken 50320 times.
✗ Branch 1 not taken.
50320 cont_sfx(bgsfx);
467 50320 }
468
469
2/2
✓ Branch 0 taken 89095 times.
✓ Branch 1 taken 26134 times.
115229 if(get_qr(qr_NEWENEMYTILES))
470 {
471 89095 o_tile=d->e_tile;
472 89095 frate = d->e_frate;
473 89095 }
474 else
475 {
476 26134 o_tile=d->tile;
477 26134 frate = d->frate;
478 }
479
480 115229 tile=0; //init to 0 here, but set it later.
481
482 115229 scripttile = -1;
483 115229 scriptflip = -1;
484 115229 do_animation = true;
485 115229 immortal = false;
486 115229 noSlide = false;
487 115229 deathexstate = -1;
488
489 115229 hashero=false;
490
491 // If they forgot the invisibility flag, here's another failsafe:
492
4/4
✓ Branch 0 taken 5793 times.
✓ Branch 1 taken 109436 times.
✓ Branch 2 taken 5699 times.
✓ Branch 3 taken 94 times.
115229 if(o_tile==0 && family!=eeSPINTILE)
493
1/2
✓ Branch 0 taken 5699 times.
✗ Branch 1 not taken.
5699 flags |= guy_invisible;
494
495 // step = d->step/100.0;
496 // To preserve the odd step values for Keese & Gleeok heads. -L
497
5/8
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115229 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12297 times.
✓ Branch 5 taken 102932 times.
✓ Branch 6 taken 12297 times.
✗ Branch 7 not taken.
115229 if(dstep==62.0) dstep+=0.5;
498
5/8
✓ Branch 0 taken 102932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102932 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 102233 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102932 else if(dstep==89) dstep-=1/9;
499
500
5/10
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115229 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115229 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115229 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115229 times.
✗ Branch 9 not taken.
115229 step = zslongToFix(dstep*100);
501
502
503 115229 item_set = d->item_set;
504 115229 grumble = d->grumble;
505
506
2/2
✓ Branch 0 taken 90341 times.
✓ Branch 1 taken 24888 times.
115229 if(frate == 0)
507 24888 frate = 256;
508
509 115229 leader = itemguy = dying = scored = false;
510 115229 canfreeze = count_enemy = true;
511
1/2
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
115229 mainguy = !(flags & guy_doesnt_count);
512
1/2
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
115229 dir = zc_oldrand()&3;
513
514 //2.6 Enemy Editor Hit and TIle Sizes
515
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115229 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
516 // al_trace("Enemy txsz:%i\n", txsz);
517
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115229 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
518
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115222 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115229 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
519
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115222 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115229 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115229 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115229 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
521
1/2
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
115229 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
522
1/2
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
115229 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
523 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115229 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115229 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115229 times.
115229 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
526 {
527 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
528 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
529 }
530
531
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115229 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115229 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
532
533 115229 SIZEflags = d->SIZEflags;
534
535
8/10
✓ Branch 0 taken 114980 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114863 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
115229 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
536 1 wpn = 0;
537
538 //tile should never be 0 after init --Z (failsafe)
539
4/6
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115229 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107988 times.
✓ Branch 5 taken 7241 times.
115229 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
540
541 //Moveflags; for gravity and pit interaction
542 115229 moveflags = d->moveflags;
543
3/4
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17696 times.
✓ Branch 3 taken 97533 times.
115229 if(!can_pitfall(false))
544 {
545 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
546
2/4
✓ Branch 0 taken 17696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17696 times.
✗ Branch 3 not taken.
17696 moveflags &= ~move_can_pitfall;
547
2/4
✓ Branch 0 taken 17696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17696 times.
✗ Branch 3 not taken.
17696 moveflags &= ~move_can_waterdrown;
548 17696 }
549
550 115229 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
551
552 115229 specialsfx = d->specialsfx;
553
1/2
✓ Branch 0 taken 115229 times.
✗ Branch 1 not taken.
115229 weap_data = d->weap_data;
554 115229 }
555
556 114972 enemy::~enemy()
557 114972 {
558
2/4
✓ Branch 0 taken 114972 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114972 times.
✗ Branch 3 not taken.
114972 FFCore.destroyScriptableObject(ScriptType::NPC, getUID());
559
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114959 times.
114972 if(hashero)
560 {
561
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
562 13 hashero=false;
563 13 }
564 114972 }
565
566 bool enemy::is_move_paused()
567 {
568 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
569 }
570
571 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
572 {
573 7024 int32_t yg = (special==spw_floater)?8:0;
574 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
575
576
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
577 input_x = dx;
578
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
579 input_y = dy;
580
581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
582
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
583
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (world_w-16+nb)) || ((input_y+hit_height-1) >= (world_h-16+nb))))
584 return true;
585
586
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
587 {
588 if(ispitfall(dx,dy))
589 return true;
590 }
591
592 7024 bool flying = false;
593 7024 bool cansolid = false;
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 if(moveflags & move_ignore_solidity)
595 cansolid = true;
596
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
597 {
598 case spw_clipbottomright:
599 if(dy>=128 || dx>=208) return true;
600 break;
601 case spw_clipright:
602 break; //if(input_x>=208) return true; break;
603
604 case spw_wizzrobe: // fall through
605 case spw_floater: // Special case for fliers and wizzrobes - hack!
606 {
607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon(screen_spawned) && !(moveflags & move_ignore_screenedge))
608 {
609 if(dy < 32-yg || dy >= 144) return true;
610 if(dx < 32 || dx >= 224) return true;
611 }
612
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
613 return true;
614 317 cansolid = true;
615 317 flying = true;
616 }
617 317 }
618
619 7024 dx = TRUNCATE_HALF_TILE(dx);
620 7024 dy = TRUNCATE_HALF_TILE(dy);
621
622
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
623
624
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx >= world_w || dy < 0 || dy >= world_h)
625 return !(moveflags & move_ignore_screenedge);
626
627 // TODO: could this reuse _walkflag?
628
629 //_walkflag code
630 7024 mapscr* s0 = get_scr_for_world_xy_layer(dx, dy, 0);
631
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 mapscr* s1 = s0->layermap[0]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 1) : nullptr;
632
2/2
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
7024 mapscr* s2 = s0->layermap[1]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 2) : nullptr;
633
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 if (!s1 || !s1->valid) s1 = s0;
634
4/4
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
✓ Branch 2 taken 383 times.
✓ Branch 3 taken 655 times.
7024 if (!s2 || !s2->valid) s2 = s0;
635
636 7024 int32_t cpos = COMBOPOS(dx%256, dy%176);
637
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 int32_t ci = s0->data[cpos], ci1 = (s1?s1:s0)->data[cpos], ci2 = (s2?s2:s0)->data[cpos];
638 7024 newcombo c = combobuf[ci];
639
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 newcombo c1 = combobuf[ci1];
640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 newcombo c2 = combobuf[ci2];
641
642 7024 int32_t b=1;
643
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
644
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
645
646 #define iwtr(cmb, x, y, shallow) \
647 (shallow \
648 ? iswaterex_z3(cmb, -1, dx, dy, false, false, false, true, false) \
649 && !iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false) \
650 : iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false))
651
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool wtr = iwtr(ci, dx, dy, false);
652
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3473 times.
✓ Branch 3 taken 3551 times.
✓ Branch 4 taken 3473 times.
✗ Branch 5 not taken.
7024 bool shwtr = iwtr(ci, dx, dy, true);
653
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool pit = ispitfall(dx,dy);
654
655
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 90 times.
✗ Branch 7 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
656
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
657
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needwtr = (moveflags & move_only_waterwalk);
658
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
659
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needpit = (moveflags & move_only_pitwalk);
660
661
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
662 {
663 6707 int32_t cwalkflag = c.walk & 0xF;
664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
666 {
667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
668 {
669 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
670 {
671 int efflag = (c1.walk & 0xF0)>>4;
672 int newsolid = (c1.walk & 0xF);
673 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
674 }
675 else cwalkflag &= c1.walk;
676 }
677 6707 else cwalkflag |= c1.walk & 0xF;
678 6707 }
679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s2)
680 {
681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c2.type == cBRIDGE)
682 {
683 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
684 {
685 int efflag = (c2.walk & 0xF0)>>4;
686 int newsolid = (c2.walk & 0xF);
687 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
688 }
689 else cwalkflag &= c2.walk;
690 }
691 6707 else cwalkflag |= c2.walk & 0xF;
692 6707 }
693
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
694 239 return true;
695 6468 }
696
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
697 {
698 bool ret = true;
699 if (needwtr && wtr) ret = false;
700 else if (needshwtr && shwtr) ret = false;
701 else if (needpit && pit) ret = false;
702 return ret;
703 }
704
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
705 return true;
706
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
707 return true;
708
709 6785 return false;
710 7024 }
711
712 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
713 {
714
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
715 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
716 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
717
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
718 {
719 if((moveflags & move_obeys_grav) && isSideViewGravity())
720 return false;
721 }
722
723
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
724
725
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
726 {
727
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
728 {
729
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
730 770 int mx = (bx+dx).getFloor();
731
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
732 {
733
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
734 return false;
735 2976 }
736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
737 return false;
738
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
739 return false;
740 770 }
741 else
742 {
743 341 int mx = (rx+dx).getCeil();
744 341 int lx = mx-hit_width+1;
745
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
746 {
747
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
748 1 return false;
749 2141 }
750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
751 return false;
752
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
753 return false;
754 }
755 1110 }
756
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
757 {
758
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
759 {
760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
761 315 int my = (by+dy).getFloor();
762
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
763 {
764
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
765 238 return false;
766 154 }
767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
768 return false;
769
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
770 return false;
771 77 }
772 else
773 {
774 109 int my = (ry+dy).getCeil();
775 109 int ly = my-hit_height+1;
776
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
777 {
778
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
779 return false;
780 218 }
781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
782 return false;
783
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
784 return false;
785 }
786 186 }
787 else //! Untested, and currently unused.
788 {
789 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
790 }
791 1296 return true;
792 1535 }
793
794 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
795 {
796 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
797 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
798
799 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
800
801 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
802 return false;
803 for(zfix ty = 0; by+ty < ry; ty += 8)
804 {
805 for(zfix tx = 0; bx+tx < rx; tx += 8)
806 {
807 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
808 return false;
809 }
810 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
811 return false;
812 }
813 for(zfix tx = 0; bx+tx < rx; tx += 8)
814 {
815 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
816 return false;
817 }
818 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
819 return false;
820 return true;
821 }
822
823 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
824 {
825 auto oxsz = hit_width, oysz = hit_height;
826 if(nwid > -1) hit_width = nwid;
827 if(nhei > -1) hit_height = nhei;
828 bool ret = scr_canplace(dx,dy,special,kb);
829 hit_width = oxsz; hit_height = oysz;
830 return ret;
831 }
832
833 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
834 {
835 1311 bool ret = true;
836
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
837 dy = 0;
838 1311 const int scl = 2;
839
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
840 {
841
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
842 {
843 260 int32_t tdx = dx.sign() * scl;
844
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
845 260 dx -= tdx;
846 else
847 {
848 if(earlyret) return false;
849 dx = tdx;
850 ret = false;
851 }
852 260 }
853 else
854 {
855 34 int32_t tdy = dy.sign() * scl;
856
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
857 27 dy -= tdy;
858 else
859 {
860
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
861 7 dy = tdy;
862 7 ret = false;
863 }
864 }
865 }
866
867
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
868 {
869
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
870 1110 x += dx;
871 else
872 {
873
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
874 ret = false;
875 int xsign = dx.sign();
876 while(scr_canmove(xsign, 0, special, kb, ign_sv))
877 {
878 x += xsign;
879 dx -= xsign;
880 }
881 if(dx)
882 {
883 dx.doDecBound(0,-9999, 0,9999);
884 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
885 if(scr_canmove(val, 0, special, kb, ign_sv))
886 {
887 retval = val;
888 return BSEARCH_CONTINUE_AWAY0;
889 }
890 else return BSEARCH_CONTINUE_TOWARD0;
891 });
892 x += dx;
893 }
894 }
895 1110 }
896
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
897 {
898
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
899 186 y += dy;
900 else
901 {
902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
903 14 ret = false;
904 14 int ysign = dy.sign();
905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
906 {
907 y += ysign;
908 dy -= ysign;
909 }
910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
911 {
912 14 dy.doDecBound(0,-9999, 0,9999);
913
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
915 {
916 retval = val;
917 return BSEARCH_CONTINUE_AWAY0;
918 }
919 210 else return BSEARCH_CONTINUE_TOWARD0;
920 210 });
921 14 y += dy;
922 14 }
923 }
924 200 }
925 1310 return ret;
926 1311 }
927
928 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
929 {
930
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
931
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
932 {
933 case up:
934 return movexy(0, -px, special, kb, false, earlyret);
935 case down:
936 16 return movexy(0, px, special, kb, false, earlyret);
937 case left:
938 479 return movexy(-px, 0, special, kb, false, earlyret);
939 case right:
940 259 return movexy(px, 0, special, kb, false, earlyret);
941 case r_up:
942 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
943 case r_down:
944 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
945 case l_up:
946 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
947 case l_down:
948 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
949 }
950 return false;
951 754 }
952
953 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
954 {
955 double v = degrees.getFloat() * PI / 180.0;
956 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
957 return movexy(dx, dy, special, kb, false, earlyret);
958 }
959
960 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
961 {
962 zfix tx = x, ty = y;
963 bool ret = movexy(dx, dy, special, kb, false, true);
964 x = tx;
965 y = ty;
966 return ret;
967 }
968 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
969 {
970 754 zfix tx = x, ty = y;
971 754 bool ret = moveDir(dir, px, special, kb, true);
972 754 x = tx;
973 754 y = ty;
974 754 return ret;
975 }
976 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
977 {
978 zfix tx = x, ty = y;
979 bool ret = moveAtAngle(degrees, px, special, kb, true);
980 x = tx;
981 y = ty;
982 return ret;
983 }
984
985 // Handle pitfalls
986 38009489 bool enemy::do_falling(int32_t index)
987 {
988
2/2
✓ Branch 0 taken 38007122 times.
✓ Branch 1 taken 2367 times.
38009489 if(fallclk > 0)
989 {
990
4/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2333 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 20 times.
2367 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
991
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 22 times.
2367 if(!--fallclk)
992 {
993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
994 ++fallclk; //force another frame of falling.... forever.
995
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
996 {
997
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
998 never_return(screen_spawned, index);
999
1000
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1001 kill_em_all();
1002
1003 //leave_item(); //Don't drop items in pits!
1004 11 stop_bgsfx(index);
1005 11 return true;
1006 }
1007 else
1008 {
1009 11 try_death(true); //Force death
1010 11 ++fallclk; //force another frame of falling
1011 }
1012 11 }
1013
1014 2356 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1015 2356 cs = spr.csets & 0xF;
1016
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t fr = spr.frames ? spr.frames : 1;
1017
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t spd = spr.speed ? spr.speed : 1;
1018 2356 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1019
2/2
✓ Branch 0 taken 1148 times.
✓ Branch 1 taken 1208 times.
2356 tile = spr.tile + zc_min(animclk / spd, fr-1);
1020 2356 }
1021 38009478 return false;
1022 38009489 }
1023
1024 // Handle drowning in water
1025 38007122 bool enemy::do_drowning(int32_t index)
1026 {
1027
1/2
✓ Branch 0 taken 38007122 times.
✗ Branch 1 not taken.
38007122 if(drownclk > 0)
1028 {
1029 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1030 //!TODO: Drown SFX
1031 if(!--drownclk)
1032 {
1033 if(immortal) //Keep alive forever
1034 ++drownclk; //force another frame of falling.... forever.
1035 else if(dying) //Give 1 frame for script revival
1036 {
1037 if(flags&guy_never_return)
1038 never_return(screen_spawned, index);
1039
1040 if(leader)
1041 kill_em_all();
1042
1043 //leave_item(); //Don't drop items in pits!
1044 stop_bgsfx(index);
1045 return true;
1046 }
1047 else
1048 {
1049 try_death(true); //Force death
1050 ++drownclk; //force another frame of falling
1051 }
1052 }
1053
1054 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1055 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1056 cs = spr.csets & 0xF;
1057 int32_t fr = spr.frames ? spr.frames : 1;
1058 int32_t spd = spr.speed ? spr.speed : 1;
1059 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1060 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1061 }
1062 38007122 return false;
1063 38007122 }
1064
1065 // Supplemental animation code that all derived classes should call
1066 // as a return value for animate().
1067 // Handles the death animation and returns true when enemy is finished.
1068 38672330 bool enemy::Dead(int32_t index)
1069 {
1070
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38670501 times.
38672330 if(immortal)
1071 {
1072 1829 dying = false;
1073 1829 return false;
1074 }
1075
2/2
✓ Branch 0 taken 765389 times.
✓ Branch 1 taken 37905112 times.
38670501 if(dying)
1076 {
1077
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 765388 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
765389 if(deathexstate > -1 && deathexstate < 32)
1078 {
1079 1 setxmapflag(screen_spawned, 1<<deathexstate);
1080 1 deathexstate = -1;
1081 1 }
1082 765389 --clk2;
1083
1084
4/4
✓ Branch 0 taken 725486 times.
✓ Branch 1 taken 39903 times.
✓ Branch 2 taken 38736 times.
✓ Branch 3 taken 3233 times.
765389 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1085
2/2
✓ Branch 0 taken 41969 times.
✓ Branch 1 taken 683517 times.
725486 && hp>-1000) // not killed by ringleader
1086 38736 death_sfx();
1087
1088
2/2
✓ Branch 0 taken 721865 times.
✓ Branch 1 taken 43524 times.
765389 if(clk2==0)
1089 {
1090
2/2
✓ Branch 0 taken 42821 times.
✓ Branch 1 taken 703 times.
43524 if(flags&guy_never_return)
1091 703 never_return(screen_spawned, index);
1092
1093
2/2
✓ Branch 0 taken 43453 times.
✓ Branch 1 taken 71 times.
43524 if(leader)
1094 71 kill_em_all();
1095
1096 43524 leave_item();
1097 43524 }
1098
1099 765389 stop_bgsfx(index);
1100 765389 return (clk2==0);
1101 }
1102
1103 37905112 return false;
1104 38672330 }
1105
1106 // Basic animation code that all derived classes should call.
1107 // The one with an index is the one that is called by
1108 // the guys sprite list; index is the enemy's index in the list.
1109 38009745 bool enemy::animate(int32_t index)
1110 {
1111
2/2
✓ Branch 0 taken 1723938 times.
✓ Branch 1 taken 36285807 times.
38009745 if(sclk <= 0) hitdir = -1;
1112
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 38009489 times.
38009745 if(switch_hooked)
1113 {
1114
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1115 {
1116 //Run its script
1117 if (!didScriptThisFrame)
1118 {
1119 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1120 {
1121 return 0; //Avoid NULLPO if this object deleted itself
1122 }
1123 }
1124 }
1125 256 return false;
1126 }
1127
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 38009478 times.
38009489 if(do_falling(index)) return true;
1128
2/2
✓ Branch 0 taken 2356 times.
✓ Branch 1 taken 38007122 times.
38009478 else if(fallclk)
1129 {
1130 //clks
1131
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 704 times.
2356 if(hclk>0)
1132 704 --hclk;
1133
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(stunclk>0)
1134 --stunclk;
1135
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if ( frozenclock > 0 )
1136 --frozenclock;
1137
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(hashero)
1138 {
1139 Hero.setX(x);
1140 Hero.setY(y);
1141 Hero.fallCombo = fallCombo;
1142 Hero.fallclk = fallclk;
1143
1144 if(hashero)
1145 {
1146 hashero = false; //Let Hero go if falling
1147 Hero.setEaten(0);
1148 }
1149 }
1150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356 times.
2356 if (!didScriptThisFrame)
1151 {
1152 2356 run_script(MODE_NORMAL);
1153 2356 }
1154 2356 return false;
1155 }
1156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38007122 times.
38007122 if(do_drowning(index)) return true;
1157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38007122 times.
38007122 else if(drownclk)
1158 {
1159 //clks
1160 if(hclk>0)
1161 --hclk;
1162 if(stunclk>0)
1163 --stunclk;
1164 if ( frozenclock > 0 )
1165 --frozenclock;
1166 if(hashero)
1167 {
1168 Hero.setX(x);
1169 Hero.setY(y);
1170 Hero.drownclk = drownclk;
1171
1172 if(hashero)
1173 {
1174 hashero = false; //Let Hero go if falling
1175 Hero.setEaten(0);
1176 }
1177 }
1178 if (!didScriptThisFrame)
1179 {
1180 run_script(MODE_NORMAL);
1181 }
1182 return false;
1183 }
1184 38007122 int32_t nx = real_x(x);
1185 38007122 int32_t ny = real_y(y);
1186
1187
4/4
✓ Branch 0 taken 27478844 times.
✓ Branch 1 taken 10528278 times.
✓ Branch 2 taken 5660005 times.
✓ Branch 3 taken 21818839 times.
38007122 if(ox!=nx || oy!=ny)
1188 {
1189 16188283 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1190 16188283 }
1191
1192 38007122 ox = nx;
1193 38007122 oy = ny;
1194
1195 // Maybe they fell off the bottom in sideview, or were moved by a script.
1196
1197 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1198
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38005293 times.
38007122 if ( immortal )
1199 {
1200 //skip, as it can go out of bounds, from immortality
1201 1829 }
1202
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38005293 times.
✓ Branch 2 taken 38005293 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38005293 times.
38005293 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1203 {
1204 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1205 }
1206
2/2
✓ Branch 0 taken 37973692 times.
✓ Branch 1 taken 31601 times.
38005293 else if (OUTOFBOUNDS(id, x, y))
1207 {
1208 31601 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1209 31601 }
1210 //fall down
1211
6/6
✓ Branch 0 taken 27190689 times.
✓ Branch 1 taken 10816433 times.
✓ Branch 2 taken 10546170 times.
✓ Branch 3 taken 27460952 times.
✓ Branch 4 taken 511411 times.
✓ Branch 5 taken 10034759 times.
38007122 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1212 {
1213
2/2
✓ Branch 0 taken 387698 times.
✓ Branch 1 taken 9647061 times.
10034759 if(isSideViewGravity())
1214 {
1215
1/2
✓ Branch 0 taken 387698 times.
✗ Branch 1 not taken.
387698 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1216 {
1217
2/2
✓ Branch 0 taken 230320 times.
✓ Branch 1 taken 157378 times.
387698 if(!isOnSideviewPlatform())
1218 {
1219 157378 bool willHitSVPlatform = false;
1220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1222
2/2
✓ Branch 0 taken 157378 times.
✓ Branch 1 taken 157378 times.
314756 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1223 {
1224
5/8
✓ Branch 0 taken 23519 times.
✓ Branch 1 taken 133859 times.
✓ Branch 2 taken 23519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157378 times.
✗ Branch 7 not taken.
157378 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1225 {
1226 willHitSVPlatform = true;
1227 break;
1228 }
1229 157378 }
1230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 if(willHitSVPlatform)
1231 {
1232 y+=fall/100;
1233 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1234 do_fix(y, 16); //Fix to top of SV Ladder
1235 fall = 0;
1236 }
1237 else
1238 {
1239 157378 y+=fall/100;
1240
2/2
✓ Branch 0 taken 17812 times.
✓ Branch 1 taken 139566 times.
157378 if(fall <= (int32_t)zinit.terminalv)
1241 139566 fall += (zinit.gravity/100);
1242 }
1243 157378 }
1244 else
1245 {
1246
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 230043 times.
230320 if(fall!=0) // Only fix pos once
1247 {
1248 //y-=(int32_t)y%8; // Fix position
1249 277 do_fix(y, 8); //Fix position
1250 277 }
1251
1252 230320 fall = 0;
1253 }
1254 387698 }
1255 else
1256 {
1257 if(isOnSideviewPlatform())
1258 fall = 0;
1259 else
1260 {
1261 zfix fall_amnt = fall/100;
1262 bool hit = false;
1263 while(fall_amnt >= 1)
1264 {
1265 --fall_amnt;
1266 ++y;
1267 if(isOnSideviewPlatform())
1268 {
1269 y = y.getInt();
1270 fall_amnt = 0;
1271 hit = true;
1272 break;
1273 }
1274 }
1275 if(fall_amnt > 0)
1276 y += fall_amnt;
1277 if(fall_amnt < 0)
1278 {
1279 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1280 hit = true;
1281 }
1282 if(hit)
1283 fall = 0;
1284 else if(fall <= (int32_t)zinit.terminalv)
1285 fall += (zinit.gravity/100);
1286 }
1287 }
1288 387698 }
1289 else
1290 {
1291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647061 times.
9647061 if (!(moveflags & move_no_fake_z))
1292 {
1293
2/2
✓ Branch 0 taken 5078998 times.
✓ Branch 1 taken 4568063 times.
9647061 if(fakefall!=0)
1294 4568063 fakez-=(fakefall/100);
1295
1296
2/2
✓ Branch 0 taken 4568063 times.
✓ Branch 1 taken 5078998 times.
9647061 if(fakez<0)
1297 4568063 fakez = fakefall = 0;
1298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5078998 times.
5078998 else if(fakefall <= (int32_t)zinit.terminalv)
1299 5078998 fakefall += (zinit.gravity/100);
1300
1301
5/6
✓ Branch 0 taken 9647061 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5078998 times.
✓ Branch 3 taken 4568063 times.
✓ Branch 4 taken 4582310 times.
✓ Branch 5 taken 496688 times.
9647061 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1302 9647061 }
1303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647061 times.
9647061 if (!(moveflags & move_no_real_z))
1304 {
1305
2/2
✓ Branch 0 taken 5511884 times.
✓ Branch 1 taken 4135177 times.
9647061 if(fall!=0)
1306 4135177 z-=(fall/100);
1307
1308
2/2
✓ Branch 0 taken 4120605 times.
✓ Branch 1 taken 5526456 times.
9647061 if(z<0)
1309 4120605 z = fall = 0;
1310
2/2
✓ Branch 0 taken 10057 times.
✓ Branch 1 taken 5516399 times.
5526456 else if(fall <= (int32_t)zinit.terminalv)
1311 5516399 fall += (zinit.gravity/100);
1312
1313
6/6
✓ Branch 0 taken 9604847 times.
✓ Branch 1 taken 42214 times.
✓ Branch 2 taken 5484242 times.
✓ Branch 3 taken 4120605 times.
✓ Branch 4 taken 4990689 times.
✓ Branch 5 taken 493553 times.
9647061 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1314 9647061 }
1315
1316 }
1317 10034759 }
1318
4/4
✓ Branch 0 taken 37491655 times.
✓ Branch 1 taken 515467 times.
✓ Branch 2 taken 9226612 times.
✓ Branch 3 taken 28265043 times.
38007122 if(!isSideViewGravity() && (moveflags & move_can_pitfall))
1319 {
1320
8/10
✓ Branch 0 taken 9199972 times.
✓ Branch 1 taken 26640 times.
✓ Branch 2 taken 9160314 times.
✓ Branch 3 taken 39658 times.
✓ Branch 4 taken 9160314 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9199972 times.
✓ Branch 8 taken 9160314 times.
✓ Branch 9 taken 9160314 times.
9226612 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1321 {
1322 9160314 fallCombo = check_pits();
1323 9160314 }
1324 27547240 }
1325
4/4
✓ Branch 0 taken 37491655 times.
✓ Branch 1 taken 18836095 times.
✓ Branch 2 taken 146897 times.
✓ Branch 3 taken 37344758 times.
56327750 if(!isSideViewGravity() && (moveflags & move_can_waterdrown))
1326 {
1327
8/10
✓ Branch 0 taken 142951 times.
✓ Branch 1 taken 3946 times.
✓ Branch 2 taken 141898 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 141898 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 142951 times.
✓ Branch 8 taken 141898 times.
✓ Branch 9 taken 141898 times.
146897 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1328 {
1329 141898 drownCombo = check_water();
1330 141898 }
1331 430693 }
1332
1333 56611546 runKnockback(); //scripted knockback handling
1334
1335 // clk is incremented here
1336
2/2
✓ Branch 0 taken 54301210 times.
✓ Branch 1 taken 2310336 times.
56611546 if(++clk >= frate)
1337 2310336 clk=0;
1338
1339 // hit and death handling
1340
2/2
✓ Branch 0 taken 1255627 times.
✓ Branch 1 taken 55355919 times.
56611546 if(hclk>0)
1341 1255627 --hclk;
1342
1343
2/2
✓ Branch 0 taken 676245 times.
✓ Branch 1 taken 55935301 times.
56611546 if(stunclk>0)
1344 676245 --stunclk;
1345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56611546 times.
56611546 if ( frozenclock > 0 )
1346 --frozenclock;
1347
1348
5/6
✓ Branch 0 taken 14876 times.
✓ Branch 1 taken 56596670 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 14752 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 124 times.
56611546 if(ceiling && z <= 0 && fakez <= 0)
1349 124 ceiling = false;
1350
1351 56611546 try_death();
1352
1353 56611546 scored=false;
1354
1355 56611546 ++c_clk;
1356
1357 //Run its script
1358
2/2
✓ Branch 0 taken 18629241 times.
✓ Branch 1 taken 37982305 times.
56611546 if (!didScriptThisFrame)
1359 {
1360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37982305 times.
37982305 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1361 {
1362 return 0; //Avoid NULLPO if this object deleted itself
1363 }
1364 37982305 }
1365
1366 // returns true when enemy is defeated
1367 56611546 return Dead(index);
1368 56614169 }
1369
1370 38759253 bool enemy::setSolid(bool set)
1371 {
1372
1/2
✓ Branch 0 taken 38759253 times.
✗ Branch 1 not taken.
38759253 bool actual = set && !isSubmerged();
1373 38759253 bool ret = solid_object::setSolid(actual);
1374 38759253 solid = set;
1375 38759253 return ret;
1376 }
1377 void enemy::doContactDamage(int32_t hdir)
1378 {
1379 Hero.hithero(guys.find(this), hdir);
1380 }
1381
1382 22405 void enemy::solid_push(solid_object *obj)
1383 {
1384
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1386 22405 zfix dx, dy;
1387 22405 int32_t hdir = -1;
1388 22405 solid_push_int(obj,dx,dy,hdir,true);
1389
1390
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1391
1392 263 bool t = obj->getTempNonsolid();
1393 263 obj->setTempNonsolid(true);
1394
1395 263 int32_t ydir = dy > 0 ? down : up;
1396 263 int32_t xdir = dx > 0 ? right : left;
1397
1398 263 auto special = isflier(id) ? spw_floater : spw_none;
1399
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1400 {
1401 //Crushed?
1402 7 }
1403
1404 263 obj->setTempNonsolid(t);
1405 22405 }
1406 22405 bool enemy::is_unpushable() const
1407 {
1408 22405 return isSubmerged();
1409 }
1410 22087 bool enemy::sideview_mode() const
1411 {
1412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1413 }
1414
1415 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1416 {
1417 3234 int32_t yg = (special==spw_floater)?8:0;
1418 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1419
1420
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1421 4732 return true;
1422
1423 3238 bool isInDungeon = isdungeon(screen_spawned);
1424
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1425 {
1426
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1427 1199 return true;
1428
1429
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1430
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1431 return true;
1432 595 }
1433
1434
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1435 {
1436
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1437
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1438 return true;
1439 62 }
1440
1441
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1442 {
1443 case spw_clipbottomright:
1444 if(dy>=128 || dx>=208) return true;
1445 break;
1446 case spw_clipright:
1447 break; //if(x>=208) return true; break;
1448
1449 case spw_wizzrobe: // fall through
1450 case spw_floater: // Special case for fliers and wizzrobes - hack!
1451 {
1452
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1453 {
1454
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1455
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1456 595 }
1457 857 return false;
1458 }
1459 }
1460
1461 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1462 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1463
1464 if(special==spw_water)
1465 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1466
1467 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1468 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1469 870 }
1470
1471 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1472 {
1473 6575 bool kb = false;
1474 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1475
1476
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1477 return true;
1478
1479
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon(screen_spawned))
1480 {
1481
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=world_h-32))
1482 return true;
1483
1484
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=world_w-32))
1485 return true;
1486 1513 }
1487
1488
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1489 {
1490
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1491
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1492 return true;
1493 6575 }
1494
1495
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1496 {
1497
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1499 }
1500 else
1501 {
1502
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1503
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1504
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1506 }
1507 6575 }
1508
1509 // returns true if cannot walk
1510 32505188 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1511 {
1512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32505188 times.
32505188 if(moveflags & move_new_movement)
1513 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1514 32505188 int32_t yg = (special==spw_floater)?8:0;
1515 32505188 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1516
2/2
✓ Branch 0 taken 3724333 times.
✓ Branch 1 taken 28780855 times.
32505188 switch(dir)
1517 {
1518 case l_down:
1519 case r_down:
1520 case down:
1521 case 11: //r_down
1522 case 12: //down
1523 case 13: //l_down
1524 {
1525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3724333 times.
3724333 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1526 {
1527
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3724325 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3724333 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1528 {
1529 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1530
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1531 8 }
1532 3724333 }
1533 3724333 break;
1534 }
1535 }
1536
2/2
✓ Branch 0 taken 3726320 times.
✓ Branch 1 taken 28778868 times.
32505188 switch(dir)
1537 {
1538 case r_up:
1539 case r_down:
1540 case right:
1541 case 9: //r_up
1542 case 10: //right
1543 case 11: //r_down
1544 {
1545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3726320 times.
3726320 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1546 {
1547
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3726317 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3726320 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1548 {
1549 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1550
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1551 3 }
1552 3726320 }
1553 3726320 break;
1554 }
1555 }
1556
1557
10/10
✓ Branch 0 taken 22401493 times.
✓ Branch 1 taken 10103695 times.
✓ Branch 2 taken 8754298 times.
✓ Branch 3 taken 1349397 times.
✓ Branch 4 taken 10066519 times.
✓ Branch 5 taken 37176 times.
✓ Branch 6 taken 10043316 times.
✓ Branch 7 taken 23203 times.
✓ Branch 8 taken 22454485 times.
✓ Branch 9 taken 32497801 times.
32505188 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1558 44916357 return true;
1559
1560 32497801 bool isInDungeon = isdungeon(screen_spawned);
1561
4/4
✓ Branch 0 taken 3976538 times.
✓ Branch 1 taken 28521263 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3964782 times.
32497801 if(isInDungeon || special==spw_wizzrobe)
1562 {
1563
8/8
✓ Branch 0 taken 5892122 times.
✓ Branch 1 taken 22640897 times.
✓ Branch 2 taken 5667647 times.
✓ Branch 3 taken 224475 times.
✓ Branch 4 taken 5820235 times.
✓ Branch 5 taken 17045137 times.
✓ Branch 6 taken 5820048 times.
✓ Branch 7 taken 187 times.
28533019 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=world_h-32 && dy>=world_h-32))
1564 11487695 return true;
1565
1566
8/8
✓ Branch 0 taken 5739754 times.
✓ Branch 1 taken 11305570 times.
✓ Branch 2 taken 5573239 times.
✓ Branch 3 taken 166515 times.
✓ Branch 4 taken 5688188 times.
✓ Branch 5 taken 5783897 times.
✓ Branch 6 taken 5687234 times.
✓ Branch 7 taken 954 times.
17045324 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<world_w-32 && dx>=world_w-32))
1567
2/2
✓ Branch 0 taken 113901 times.
✓ Branch 1 taken 94 times.
11260473 if(special!=spw_door) // walk in door way
1568 113901 return true;
1569 5784945 }
1570
1571
6/6
✓ Branch 0 taken 3102311 times.
✓ Branch 1 taken 6647416 times.
✓ Branch 2 taken 750683 times.
✓ Branch 3 taken 2351628 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 699453 times.
9749727 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1572 {
1573
4/4
✓ Branch 0 taken 3044664 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3043712 times.
6094843 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1574
4/4
✓ Branch 0 taken 3044481 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3043762 times.
✓ Branch 3 taken 719 times.
3044664 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1575 7369 return true;
1576 3043712 }
1577
1578
4/4
✓ Branch 0 taken 7555685 times.
✓ Branch 1 taken 2180419 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9742358 switch(special)
1579 {
1580 case spw_clipbottomright:
1581
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=world_h-48 || dx>=world_w-48) return true;
1582 707 break;
1583 case spw_clipright:
1584 5281 break; //if(input_x>=208) return true; break;
1585
1586 case spw_wizzrobe: // fall through
1587 case spw_floater: // Special case for fliers and wizzrobes - hack!
1588 {
1589
2/2
✓ Branch 0 taken 2914018 times.
✓ Branch 1 taken 4641667 times.
7555685 if(isInDungeon)
1590 {
1591
3/4
✓ Branch 0 taken 4641655 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641655 times.
4641667 if(dy < 32-yg || dy >= world_h-32) return true;
1592
4/4
✓ Branch 0 taken 4639543 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639527 times.
4641655 if(dx < 32 || dx >= world_w-32) return true;
1593 4639527 }
1594 7553545 return false;
1595 }
1596 }
1597
1598 2186407 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1599
2/2
✓ Branch 0 taken 486589 times.
✓ Branch 1 taken 1699818 times.
2186407 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1600
1601
2/2
✓ Branch 0 taken 414677 times.
✓ Branch 1 taken 1771730 times.
2186407 if(special==spw_water)
1602
2/2
✓ Branch 0 taken 16749 times.
✓ Branch 1 taken 397928 times.
414677 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1603
1604
2/2
✓ Branch 0 taken 1711826 times.
✓ Branch 1 taken 59904 times.
1771730 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1605 {
1606
4/4
✓ Branch 0 taken 1228145 times.
✓ Branch 1 taken 483681 times.
✓ Branch 2 taken 1218108 times.
✓ Branch 3 taken 10037 times.
2929934 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1607
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203528 times.
1218108 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1608 }
1609 else
1610 {
1611
4/4
✓ Branch 0 taken 42909 times.
✓ Branch 1 taken 16995 times.
✓ Branch 2 taken 42645 times.
✓ Branch 3 taken 264 times.
102549 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1612
3/4
✓ Branch 0 taken 42282 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 42282 times.
✗ Branch 3 not taken.
42645 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1613
4/4
✓ Branch 0 taken 37047 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 37032 times.
✓ Branch 3 taken 15 times.
42282 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1614
2/2
✓ Branch 0 taken 36729 times.
✓ Branch 1 taken 303 times.
37032 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1615 }
1616 10129400 }
1617
1618 496901 bool enemy::isOnSideviewPlatform()
1619 {
1620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1622
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
496901 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1623 return false;
1624
5/6
✓ Branch 0 taken 11630 times.
✓ Branch 1 taken 485271 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 11208 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422 times.
496901 if(y + usehei >= world_h && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) return true; //Bottom of the map
1625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496479 times.
496479 if(check_slope(x, y+1, usewid, usehei)) return true;
1626
2/2
✓ Branch 0 taken 496479 times.
✓ Branch 1 taken 215641 times.
712120 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1627 {
1628
2/2
✓ Branch 0 taken 215641 times.
✓ Branch 1 taken 280838 times.
496479 if(_walkflag(nx,y+usehei,1)) return true;
1629
3/4
✓ Branch 0 taken 215641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151313 times.
✓ Branch 3 taken 64328 times.
215641 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64328 times.
64328 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1631 64328 }
1632 215641 return false;
1633 496901 }
1634
1635 // Stops playing the given sound only if there are no enemies left to play it
1636 768301 void enemy::stop_bgsfx(int32_t index)
1637 {
1638
2/2
✓ Branch 0 taken 753210 times.
✓ Branch 1 taken 15091 times.
768301 if(bgsfx<=0)
1639 753210 return;
1640
1641 // Look for other enemies with the same bgsfx
1642
2/2
✓ Branch 0 taken 52823 times.
✓ Branch 1 taken 8787 times.
61610 for(int32_t i=0; i<guys.Count(); i++)
1643 {
1644
4/4
✓ Branch 0 taken 41750 times.
✓ Branch 1 taken 11073 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35446 times.
52823 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1645 6304 return;
1646 46519 }
1647
1648 8787 stop_sfx(bgsfx);
1649 768301 }
1650
1651
1652 // to allow for different sfx on defeating enemy
1653 40355 void enemy::death_sfx()
1654 {
1655
2/2
✓ Branch 0 taken 40070 times.
✓ Branch 1 taken 285 times.
40355 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1656 40355 }
1657
1658 void enemy::move(zfix dx,zfix dy)
1659 {
1660 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1661 {
1662 x+=dx;
1663 y+=dy;
1664 }
1665 }
1666
1667 18373284 void enemy::move(zfix s)
1668 {
1669
9/10
✓ Branch 0 taken 18373245 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 109109 times.
✓ Branch 3 taken 18264136 times.
✓ Branch 4 taken 58221 times.
✓ Branch 5 taken 50888 times.
✓ Branch 6 taken 1005 times.
✓ Branch 7 taken 57216 times.
✓ Branch 8 taken 1005 times.
✗ Branch 9 not taken.
18373284 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1670 {
1671 18372240 sprite::move(s);
1672 18372240 }
1673 18373284 }
1674
1675 43826 void enemy::leave_item()
1676 {
1677 43826 int32_t drop_item = select_dropitem(item_set, x, y);
1678 43826 int32_t thedropset = item_set;
1679
1680 43826 std::vector<int32_t> &ev = FFCore.eventData;
1681 43826 ev.clear();
1682 43826 ev.push_back(getUID());
1683 43826 ev.push_back(drop_item*10000);
1684 43826 ev.push_back(thedropset*10000);
1685
1686 43826 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1687 43826 drop_item = vbound(ev[1] / 10000,-2,255);
1688 43826 thedropset = ev[2] / 10000;
1689 43826 ev.clear();
1690
1/2
✓ Branch 0 taken 43826 times.
✗ Branch 1 not taken.
43826 if(drop_item == -2)
1691 {
1692 drop_item = select_dropitem(thedropset,x,y);
1693 }
1694
1695
6/6
✓ Branch 0 taken 16544 times.
✓ Branch 1 taken 27282 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15627 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43826 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1696 {
1697 item* itm;
1698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16375 times.
16375 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1699 {
1700 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1701 }
1702 else
1703 {
1704
8/14
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 14655 times.
✓ Branch 2 taken 1720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1720 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1720 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1720 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1720 times.
✗ Branch 13 not taken.
16375 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1705
4/8
✓ Branch 0 taken 14655 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14655 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14655 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14655 times.
✗ Branch 7 not taken.
14655 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1706 }
1707 16375 itm->from_dropset = thedropset;
1708 16375 add_item_for_screen(screen_spawned, itm);
1709
1710 16375 ev.push_back(getUID());
1711 16375 ev.push_back(itm->getUID());
1712
1713 16375 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1714 16375 ev.clear();
1715 16375 }
1716 43826 }
1717
1718 // auomatically kill off enemy (for rooms with ringleaders)
1719 402 void enemy::kickbucket()
1720 {
1721
3/4
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 370 times.
✗ Branch 3 not taken.
402 if(!superman && !(flags&guy_ignore_kill_all))
1722 370 hp=-1000; // don't call death_sfx()
1723 402 }
1724
1725 21250 bool enemy::isSubmerged() const
1726 {
1727 21250 return submerged;
1728 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1729 }
1730
1731 20952 void enemy::FireBreath(bool seekhero)
1732 {
1733
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1734 return;
1735
1736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1737 {
1738 dmisc1 = e1tEACHTILE;
1739 FireWeapon();
1740 return;
1741 }
1742
1743 20952 float fire_angle=0.0;
1744 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1745
1746
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1747 {
1748 xoff += hxofs;
1749 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1750 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1751 else
1752 xoff += (hit_width / 2) - 8;
1753 }
1754
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1755 {
1756 yoff += hyofs;
1757 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1758 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1759 else
1760 yoff += (hit_height / 2) - 8;
1761 }
1762
1763
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1764 {
1765
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1766 {
1767 case down:
1768 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1769 3079 wx=x;
1770 3079 wy=y+8;
1771 3079 break;
1772
1773 case -1:
1774 case up:
1775 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1776 3297 wx=x;
1777 3297 wy=y-8;
1778 3297 break;
1779
1780 case left:
1781 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1782 5287 wx=x-8;
1783 5287 wy=y;
1784 5287 break;
1785
1786 case right:
1787 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1788 4208 wx=x+8;
1789 4208 wy=y;
1790 4208 break;
1791 }
1792
1793
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1794 {
1795
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1801
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1802
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1803 15735 }
1804 15871 }
1805 else
1806 {
1807 5081 wx = x;
1808 5081 wy = y;
1809 }
1810
1811
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1812 20952 sfx(wpnsfx(wpn),pan(int32_t(x)));
1813
1814 20952 int32_t i=Ewpns.Count()-1;
1815 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1816 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1817
1818
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1819 {
1820 7957 ew->angular=true;
1821 7957 ew->angle=fire_angle;
1822 7957 }
1823
1824
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1825 {
1826 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1828 20359 }
1829
1830
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1831 {
1832 766199 Ewpns.swap(j,j-1);
1833 766199 }
1834 20952 }
1835
1836 44659 void enemy::FireWeapon()
1837 {
1838 /*
1839 * Type:
1840 * 0x01: Boss fireball
1841 * 0x02: Seeks Hero
1842 * 0x04: Fast projectile
1843 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1844 */
1845
1846
2/2
✓ Branch 0 taken 44528 times.
✓ Branch 1 taken 131 times.
44659 if (wpn < 1) return;
1847
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44528 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44528 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1848 return;
1849
1850
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44528 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44528 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1851 dmisc1 = e1tEACHTILE;
1852
1853 44528 int32_t xoff = 0;
1854 44528 int32_t yoff = 0;
1855
1/2
✓ Branch 0 taken 44528 times.
✗ Branch 1 not taken.
44528 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1856 {
1857 xoff += hxofs;
1858 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1859 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1860 else
1861 xoff += (hit_width / 2) - 8;
1862 }
1863
1/2
✓ Branch 0 taken 44528 times.
✗ Branch 1 not taken.
44528 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1864 {
1865 yoff += hyofs;
1866 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1867 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1868 else
1869 yoff += (hit_height / 2) - 8;
1870 }
1871
1872 // TODO(crash): check that .add succeeds.
1873
1874
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41529 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44528 switch(dmisc1)
1875 {
1876 case e1t5SHOTS: //BS-Aquamentus
1877 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1878 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1879 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1880 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1881
1882 [[fallthrough]];
1883 case e1t3SHOTSFAST:
1884 case e1t3SHOTS: //Aquamentus
1885
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1886 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1887
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1888 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1889
1890 [[fallthrough]];
1891 default:
1892
12/20
✓ Branch 0 taken 42175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42175 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42175 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42175 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42170 times.
✓ Branch 12 taken 42175 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23937 times.
✓ Branch 16 taken 42175 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42175 times.
✗ Branch 19 not taken.
42175 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1893 42175 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1894 42175 sfx(wpnsfx(wpn),pan(int32_t(x)));
1895 42175 break;
1896
1897 case e1tSLANT:
1898 {
1899 416 int32_t slant = 0;
1900
1901
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1902 246 slant = left;
1903
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1904 117 slant = right;
1905
1906
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1907 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1908 330 sfx(wpnsfx(wpn),pan(int32_t(x)));
1909 330 break;
1910 }
1911
1912 case e1t8SHOTS: //Fire Wizzrobe
1913
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1914 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1915 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1916
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1917 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1918 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1919
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1920 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1921 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1922
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1923 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1924 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1925
1926 [[fallthrough]];
1927 case e1t4SHOTS: //Stalfos 3
1928
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1929 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1930 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1931
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1932 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1933 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1934
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1935 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1936 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1937
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1938 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1939 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1940 1937 sfx(wpnsfx(wpn),pan(int32_t(x)));
1941 1937 break;
1942
1943 case e1tSUMMON: // Bat Wizzrobe
1944 {
1945 if(dmisc4==0) break; // Summon 0
1946
1947 int32_t bc=0;
1948
1949 for(int32_t gc=0; gc<guys.Count(); gc++)
1950 {
1951 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1952 {
1953 ++bc;
1954 }
1955 }
1956
1957 if(bc<=40) // Not too many enemies
1958 {
1959 int32_t kids = guys.Count();
1960 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1961
1962 for(int32_t i=0; i<bats; i++)
1963 {
1964 if(addchild(screen_spawned,x,y,dmisc3,-10, this))
1965 {
1966 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1967 }
1968 }
1969
1970 sfx(firesfx, pan(int32_t(x)));
1971 }
1972
1973 break;
1974 }
1975
1976 case e1tSUMMONLAYER: // Summoner
1977 {
1978 if(count_layer_enemies(screen_spawned)==0)
1979 {
1980 break;
1981 }
1982
1983 int32_t kids = guys.Count();
1984
1985 if(kids<40)
1986 {
1987 int32_t newguys=(zc_oldrand()%3)+1;
1988 bool summoned=false;
1989
1990 for(int32_t i=0; i<newguys; i++)
1991 {
1992 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
1993 int32_t x2=0;
1994 int32_t y2=0;
1995
1996 for(int32_t k=0; k<20; ++k)
1997 {
1998 x2=16*((zc_oldrand()%12)+2);
1999 y2=16*((zc_oldrand()%7)+2);
2000
2001 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2002 {
2003 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
2004 {
2005 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2006 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2007 {
2008 ((enemy*)guys.spr(kids+i))->fakez = 64;
2009 ((enemy*)guys.spr(kids+i))->z = 0;
2010 }
2011 }
2012
2013 summoned=true;
2014 break;
2015 }
2016 }
2017 }
2018
2019 if(summoned)
2020 {
2021 sfx(firesfx, pan(int32_t(x)));
2022 }
2023 }
2024
2025 break;
2026 }
2027 }
2028 44573 }
2029
2030
2031 // Hit the shield(s)?
2032 // Apparently, this function is only used for hookshots...
2033 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2034 {
2035
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2036 834 return false;
2037
2038 1933 bool ret = false;
2039
2040 // TODO: There must be some bitwise operations that can simplify this...
2041
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2042
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2043
2044
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2045
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2046
2047 1933 return ret;
2048 2767 }
2049
2050
2051 //! Weapon Editor for 2.6
2052 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2053
2054
2055 //converts a wqeapon ID to its defence index.
2056 127484 int32_t weaponToDefence(int32_t wid)
2057 {
2058
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64771 times.
✓ Branch 2 taken 9439 times.
✓ Branch 3 taken 25035 times.
✓ Branch 4 taken 4210 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3160 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1438 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2054 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 28 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
127484 switch(wid)
2059 {
2060 case wNone: return -1;
2061 64771 case wSword: return edefSWORD;
2062 9439 case wBeam: return edefBEAM;
2063 25035 case wBrang: return edefBRANG;
2064 4210 case wBomb: return edefBOMB;
2065 37 case wSBomb: return edefSBOMB;
2066 48 case wLitBomb: return edefBOMB;
2067 case wLitSBomb: return edefSBOMB;
2068 3160 case wArrow: return edefARROW;
2069 9836 case wFire: return edefFIRE;
2070 case wWhistle:
2071 {
2072 return edefWhistle;
2073 }
2074 case wBait: return edefBAIT;
2075 269 case wWand: return edefWAND;
2076 1438 case wMagic: return edefMAGIC;
2077 case wCatching: return -1;
2078 case wWind: return edefWIND;
2079 512 case wRefMagic: return edefREFMAGIC;
2080 1459 case wRefFireball: return edefREFBALL;
2081 case wRefRock: return edefREFROCK;
2082 2054 case wHammer: return edefHAMMER;
2083 2767 case wHookshot: return edefHOOKSHOT;
2084 610 case wHSHandle: return edefHOOKSHOT;
2085 case wHSChain: return edefHOOKSHOT;
2086 240 case wSSparkle: return edefSPARKLE;
2087 469 case wFSparkle: return edefSPARKLE;
2088 case wSmack: return -1; // is this the candle object?
2089 case wPhantom: return -1; //engine created visual effects.
2090 case wCByrna: return edefBYRNA;
2091 19 case wRefBeam: return edefREFBEAM;
2092 case wStomp: return edefSTOMP;
2093 28 case wScript1: return edefSCRIPT01;
2094 case wScript2: return edefSCRIPT02;
2095 12 case wScript3: return edefSCRIPT03;
2096 77 case wScript4: return edefSCRIPT04;
2097 case wScript5: return edefSCRIPT05;
2098 case wScript6: return edefSCRIPT06;
2099 case wScript7: return edefSCRIPT07;
2100 case wScript8: return edefSCRIPT08;
2101 case wScript9: return edefSCRIPT09;
2102 993 case wScript10: return edefSCRIPT10;
2103 case wIce: return edefICE;
2104 case wSound: return edefSONIC;
2105 1 case wThrown: return edefTHROWN;
2106 case wRefArrow: return edefREFARROW;
2107 case wRefFire: return edefREFFIRE;
2108 case wRefFire2: return edefREFFIRE2;
2109 //case wPot: return edefPOT;
2110 // case wLitZap: return edefELECTRIC;
2111 // case wZ3Sword: return edefZ3SWORD;
2112 // case wLASWord: return edefLASWORD;
2113 // case wSpinAttk: return edefSPINATTK;
2114 // case wShield: return edefSHIELD;
2115 // case wTrowel: return edefTROWEL;
2116
2117 default: return -1;
2118 }
2119 127484 }
2120
2121 127484 int32_t getDefType(weapon *w)
2122 {
2123 127484 int32_t id = getWeaponID(w);
2124 127484 int32_t edef = weaponToDefence(id);
2125
2/2
✓ Branch 0 taken 124107 times.
✓ Branch 1 taken 3377 times.
127484 if(edef == edefHOOKSHOT)
2126 {
2127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2128 return edefSwitchHook;
2129 3377 }
2130 127484 return edef;
2131 127484 }
2132
2133 227166 int32_t getWeaponID(weapon *w)
2134 {
2135 227166 int32_t usewpn = w->useweapon;
2136
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 226936 times.
227166 return (usewpn > 0) ? usewpn : w->id;
2137 }
2138
2139 127484 int32_t enemy::resolveEnemyDefence(weapon *w)
2140 {
2141 //sword edef is 9, but we're reading it at 0
2142 //,
2143 127484 int32_t weapondef = 0;
2144 127484 int32_t wdeftype = getDefType(w);
2145 127484 int32_t usedef = w->usedefense;
2146
2147
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 127484 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
127484 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2148 {
2149 weapondef = usedef*-1;
2150 }
2151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127484 times.
127484 else if(unsigned(wdeftype) < edefLAST255)
2152 {
2153 127484 weapondef = wdeftype;
2154 127484 }
2155 127484 return weapondef;
2156 }
2157
2158 138055 byte get_def_ignrflag(int32_t edef)
2159 {
2160
3/3
✓ Branch 0 taken 115085 times.
✓ Branch 1 taken 3683 times.
✓ Branch 2 taken 19287 times.
138055 switch(edef)
2161 {
2162 case edIGNORE:
2163 case edIGNOREL1:
2164 case edSTUNORIGNORE:
2165 19287 return WPNUNB_IGNR;
2166 case edSTUNORCHINK:
2167 case edCHINK:
2168 case edCHINKL1:
2169 case edCHINKL2:
2170 case edCHINKL4:
2171 case edCHINKL6:
2172 case edCHINKL8:
2173 case edCHINKL10:
2174 case edLEVELCHINK2:
2175 case edLEVELCHINK3:
2176 case edLEVELCHINK4:
2177 case edLEVELCHINK5:
2178 3683 return WPNUNB_BLOCK;
2179 }
2180 115085 return 0;
2181 138055 }
2182
2183 138055 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2184 {
2185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138055 times.
138055 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2186 switch(edef)
2187 {
2188 case edIGNORE:
2189 case edIGNOREL1:
2190 case edCHINK:
2191 case edCHINKL1:
2192 case edCHINKL2:
2193 case edCHINKL4:
2194 case edCHINKL6:
2195 case edCHINKL8:
2196 case edCHINKL10:
2197 case edLEVELCHINK2:
2198 case edLEVELCHINK3:
2199 case edLEVELCHINK4:
2200 case edLEVELCHINK5:
2201 return edNORMAL;
2202 case edSTUNORIGNORE:
2203 case edSTUNORCHINK:
2204 return edSTUNONLY;
2205 }
2206 return edef;
2207 138055 }
2208
2209 // Do we do damage?
2210 // 0: takehit returns 0
2211 // 1: takehit returns 1
2212 // -1: do damage
2213 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2214 126491 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2215 {
2216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126491 times.
126491 if(switch_hooked) return 0;
2217 126491 int32_t tempx = x;
2218 126491 int32_t tempy = y;
2219 126491 int32_t the_defence = 0;
2220
1/2
✓ Branch 0 taken 126491 times.
✗ Branch 1 not taken.
126491 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2221 {
2222 the_defence = edef*-1; //A specific defence type.
2223 }
2224 126491 else the_defence = defense[edef];
2225
2226 126491 the_defence = conv_edef_unblockable(the_defence, unblockable);
2227
2228
3/4
✓ Branch 0 taken 6623 times.
✓ Branch 1 taken 119868 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6623 times.
126491 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2229 {
2230
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6616 times.
✓ Branch 2 taken 7 times.
6623 switch(the_defence)
2231 {
2232 case edIGNORE:
2233 7 return 0;
2234 case edIGNOREL1:
2235 case edSTUNORIGNORE:
2236 if(*power <= 0)
2237 return 0;
2238 }
2239 6616 sfx(WAV_CHINK,pan(int32_t(x)));
2240 6616 return 1;
2241 }
2242
2243 119868 int32_t new_id = id;
2244 119868 int32_t effect_type = dmisc15;
2245 119868 int32_t delay_timer = 90;
2246 119868 enemy *gleeok = NULL;
2247 119868 enemy *ptra = NULL;
2248 119868 int32_t c = 0;
2249
2250
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 945 times.
✓ Branch 13 taken 17349 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93607 times.
119868 switch(the_defence)
2251 {
2252 case edREPLACE:
2253 {
2254 sclk = 0;
2255 if ( dmisc16 > 0 ) new_id = dmisc16;
2256 else new_id = id+1;
2257 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2258 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2259 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2260
2261 //Z_scripterrlog("new id is %d\n", new_id);
2262 switch(guysbuf[new_id&0xFFF].family)
2263 {
2264 //Fixme: possible enemy memory leak. (minor)
2265 case eeWALK:
2266 {
2267 enemy *e = new eStalfos(x,y,new_id,clk);
2268 guys.add(e);
2269 }
2270 break;
2271
2272 case eeLEV:
2273 {
2274 enemy *e = new eLeever(x,y,new_id,clk);
2275 guys.add(e);
2276 }
2277 break;
2278
2279 case eeTEK:
2280 {
2281 enemy *e = new eTektite(x,y,new_id,clk);
2282 guys.add(e);
2283 }
2284 break;
2285
2286 case eePEAHAT:
2287 {
2288 enemy *e = new ePeahat(x,y,new_id,clk);
2289 guys.add(e);
2290 }
2291 break;
2292
2293 case eeZORA:
2294 {
2295 enemy *e = new eZora(x,y,new_id,clk);
2296 guys.add(e);
2297 }
2298 break;
2299
2300 case eeGHINI:
2301 {
2302 enemy *e = new eGhini(x,y,new_id,clk);
2303 guys.add(e);
2304 }
2305 break;
2306
2307 case eeKEESE:
2308 {
2309 enemy *e = new eKeese(x,y,new_id,clk);
2310 guys.add(e);
2311 }
2312 break;
2313
2314 case eeWIZZ:
2315 {
2316 enemy *e = new eWizzrobe(x,y,new_id,clk);
2317 guys.add(e);
2318 }
2319 break;
2320
2321 case eePROJECTILE:
2322 {
2323 enemy *e = new eProjectile(x,y,new_id,clk);
2324 guys.add(e);
2325 }
2326 break;
2327
2328 case eeWALLM:
2329 {
2330 enemy *e = new eWallM(x,y,new_id,clk);
2331 guys.add(e);
2332 }
2333 break;
2334
2335 case eeAQUA:
2336 {
2337 enemy *e = new eAquamentus(x,y,new_id,clk);
2338 guys.add(e);
2339 e->x = x;
2340 e->y = y;
2341 }
2342 break;
2343
2344 case eeMOLD:
2345 {
2346 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2347 guys.add(e);
2348 e->x = x;
2349 e->y = y;
2350 }
2351 break;
2352
2353 case eeMANHAN:
2354 {
2355 enemy *e = new eManhandla(x,y,new_id,clk);
2356 guys.add(e);
2357 e->x = x;
2358 e->y = y;
2359 }
2360 break;
2361
2362 case eeGLEEOK:
2363 {
2364 *power = 0;
2365 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2366 guys.add(gleeok);
2367 // TODO(crash): check that .add succeeds.
2368 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2369 new_id &= 0xFFF;
2370 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2371 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2372 for(int32_t i=0; i<head_cnt; i++)
2373 {
2374 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2375 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2376 {
2377 al_trace("Gleeok head %d could not be created!\n",i+1);
2378
2379 for(int32_t j=0; j<i+1; j++)
2380 {
2381 guys.del(guys.Count()-1);
2382 }
2383
2384 break;
2385 }
2386 else
2387 {
2388 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2389 }
2390
2391 c-=guysbuf[new_id].attributes[3];
2392 }
2393 return 1;
2394 }
2395
2396 case eeGHOMA:
2397 {
2398 enemy *e = new eGohma(x,y,new_id,clk);
2399 guys.add(e);
2400 e->x = x;
2401 e->y = y;
2402 }
2403 break;
2404
2405 case eeLANM:
2406 {
2407 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2408 guys.add(e);
2409 e->x = x;
2410 e->y = y;
2411 }
2412 break;
2413
2414 case eeGANON:
2415 {
2416 enemy *e = new eGanon(x,y,new_id,clk);
2417 guys.add(e);
2418 e->x = x;
2419 e->y = y;
2420 }
2421 break;
2422
2423 case eeFAIRY:
2424 {
2425 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2426 guys.add(e);
2427 e->x = x;
2428 e->y = y;
2429 }
2430 break;
2431
2432 case eeFIRE:
2433 {
2434 enemy *e = new eFire(x,y,new_id,clk);
2435 guys.add(e);
2436 e->x = x;
2437 e->y = y;
2438 }
2439 break;
2440
2441 case eeOTHER:
2442 {
2443 enemy *e = new eOther(x,y,new_id,clk);
2444 guys.add(e);
2445 e->x = x;
2446 e->y = y;
2447 }
2448 break;
2449
2450 case eeSPINTILE:
2451 {
2452 enemy *e = new eSpinTile(x,y,new_id,clk);
2453 guys.add(e);
2454 e->x = x;
2455 e->y = y;
2456 }
2457 break;
2458
2459 // and these enemies use the misc10/misc2 value
2460 case eeROCK:
2461 {
2462 switch(guysbuf[new_id&0xFFF].attributes[9])
2463 {
2464 case 1:
2465 {
2466 enemy *e = new eBoulder(x,y,new_id,clk);
2467 guys.add(e);
2468 e->x = x;
2469 e->y = y;
2470 }
2471 break;
2472
2473 case 0:
2474 default:
2475 {
2476 enemy *e = new eRock(x,y,new_id,clk);
2477 guys.add(e);
2478 e->x = x;
2479 e->y = y;
2480 }
2481 break;
2482 }
2483
2484 break;
2485 }
2486
2487 case eeTRAP:
2488 {
2489 switch(guysbuf[new_id&0xFFF].attributes[1])
2490 {
2491 case 1:
2492 {
2493 enemy *e = new eTrap2(x,y,new_id,clk);
2494 guys.add(e);
2495 e->x = x;
2496 e->y = y;
2497 }
2498 break;
2499
2500 case 0:
2501 default:
2502 {
2503 enemy *e = new eTrap(x,y,new_id,clk);
2504 guys.add(e);
2505 e->x = x;
2506 e->y = y;
2507 }
2508 break;
2509 }
2510
2511 break;
2512 }
2513
2514 case eeDONGO:
2515 {
2516 switch(guysbuf[new_id&0xFFF].attributes[9])
2517 {
2518 case 1:
2519 {
2520 enemy *e = new eDodongo2(x,y,new_id,clk);
2521 guys.add(e);
2522 e->x = x;
2523 e->y = y;
2524 }
2525 break;
2526
2527 case 0:
2528 default:
2529 {
2530 enemy *e = new eDodongo(x,y,new_id,clk);
2531 guys.add(e);
2532 e->x = x;
2533 e->y = y;
2534 }
2535 break;
2536 }
2537
2538 break;
2539 }
2540
2541 case eeDIG:
2542 {
2543 switch(guysbuf[new_id&0xFFF].attributes[9])
2544 {
2545 case 1:
2546 {
2547 enemy *e = new eLilDig(x,y,new_id,clk);
2548 guys.add(e);
2549 e->x = x;
2550 e->y = y;
2551 }
2552 break;
2553
2554 case 0:
2555 default:
2556 {
2557 enemy *e = new eBigDig(x,y,new_id,clk);
2558 guys.add(e);
2559 e->x = x;
2560 e->y = y;
2561 }
2562 break;
2563 }
2564
2565 break;
2566 }
2567
2568 case eePATRA:
2569 {
2570 switch(guysbuf[new_id&0xFFF].attributes[9])
2571 {
2572 case 1:
2573 {
2574 if (get_qr(qr_HARDCODED_BS_PATRA))
2575 {
2576 enemy *e = new ePatraBS(x,y,new_id,clk);
2577 guys.add(e);
2578 e->x = x;
2579 e->y = y;
2580 break;
2581 }
2582 }
2583 [[fallthrough]];
2584 case 0:
2585 default:
2586 {
2587 enemy *e = new ePatra(x,y,new_id,clk);
2588 guys.add(e);
2589 e->x = x;
2590 e->y = y;
2591 }
2592 break;
2593 }
2594
2595 break;
2596 }
2597
2598 case eeGUY:
2599 {
2600 switch(guysbuf[new_id&0xFFF].attributes[9])
2601 {
2602 case 1:
2603 {
2604 enemy *e = new eTrigger(x,y,new_id,clk);
2605 guys.add(e);
2606 }
2607 break;
2608
2609 case 0:
2610 default:
2611 {
2612 enemy *e = new eNPC(x,y,new_id,clk);
2613 guys.add(e);
2614 }
2615 break;
2616 }
2617
2618 break;
2619 }
2620
2621 case eeSCRIPT01:
2622 case eeSCRIPT02:
2623 case eeSCRIPT03:
2624 case eeSCRIPT04:
2625 case eeSCRIPT05:
2626 case eeSCRIPT06:
2627 case eeSCRIPT07:
2628 case eeSCRIPT08:
2629 case eeSCRIPT09:
2630 case eeSCRIPT10:
2631 case eeSCRIPT11:
2632 case eeSCRIPT12:
2633 case eeSCRIPT13:
2634 case eeSCRIPT14:
2635 case eeSCRIPT15:
2636 case eeSCRIPT16:
2637 case eeSCRIPT17:
2638 case eeSCRIPT18:
2639 case eeSCRIPT19:
2640 case eeSCRIPT20:
2641 {
2642 enemy *e = new eScript(x,y,new_id,clk);
2643 guys.add(e);
2644 e->x = x;
2645 e->y = y;
2646 break;
2647 }
2648
2649
2650 case eeFFRIENDLY01:
2651 case eeFFRIENDLY02:
2652 case eeFFRIENDLY03:
2653 case eeFFRIENDLY04:
2654 case eeFFRIENDLY05:
2655 case eeFFRIENDLY06:
2656 case eeFFRIENDLY07:
2657 case eeFFRIENDLY08:
2658 case eeFFRIENDLY09:
2659 case eeFFRIENDLY10:
2660 {
2661 enemy *e = new eFriendly(x,y,new_id,clk);
2662 guys.add(e);
2663 e->x = x;
2664 e->y = y;
2665 break;
2666 }
2667
2668
2669 default: break;
2670 }
2671
2672 // add segments of segmented enemies
2673 int32_t c=0;
2674
2675 switch(guysbuf[new_id&0xFFF].family)
2676 {
2677 case eeMOLD:
2678 {
2679 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2680 new_id &= 0xFFF;
2681
2682 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2683 {
2684 //christ this is messy -DD
2685 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2686
2687 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2688 {
2689 al_trace("Moldorm segment %d could not be created!\n",i+1);
2690
2691 for(int32_t j=0; j<i+1; j++)
2692 guys.del(guys.Count()-1);
2693
2694 return 0;
2695 }
2696
2697 if(i>0)
2698 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2699
2700
2701 }
2702
2703 break;
2704 }
2705
2706 case eeLANM:
2707 {
2708 new_id &= 0xFFF;
2709 int32_t shft = guysbuf[new_id].attributes[1];
2710 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2711 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2712
2713 if(!guys.add(e))
2714 {
2715 al_trace("Lanmola segment 1 could not be created!\n");
2716 guys.del(guys.Count()-1);
2717 return 0;
2718 }
2719 e->x = x;
2720 e->y = y;
2721
2722
2723
2724 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2725 {
2726 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2727 if(!guys.add(e2))
2728 {
2729 al_trace("Lanmola segment %d could not be created!\n",i+1);
2730
2731 for(int32_t j=0; j<i+1; j++)
2732 guys.del(guys.Count()-1);
2733
2734 return 0;
2735 }
2736 e2->x = x;
2737 e2->y = y;
2738
2739 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2740
2741 }
2742 }
2743 break;
2744
2745 case eeMANHAN:
2746 new_id &= 0xFFF;
2747
2748 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2749 {
2750 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2751 {
2752 al_trace("Manhandla head %d could not be created!\n",i+1);
2753
2754 for(int32_t j=0; j<i+1; j++)
2755 {
2756 guys.del(guys.Count()-1);
2757 }
2758
2759 return 0;
2760 }
2761
2762
2763 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2764 }
2765
2766 break;
2767
2768 case eeGLEEOK:
2769 {
2770 /*
2771 new_id &= 0xFFF;
2772 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2773 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2774 for(int32_t i=0; i<head_cnt; i++)
2775 {
2776 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2777 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2778 {
2779 al_trace("Gleeok head %d could not be created!\n",i+1);
2780
2781 for(int32_t j=0; j<i+1; j++)
2782 {
2783 guys.del(guys.Count()-1);
2784 }
2785
2786 break;
2787 }
2788
2789 c-=guysbuf[new_id].misc4;
2790 */
2791
2792 // }
2793 }
2794 break;
2795
2796
2797 case eePATRA:
2798 {
2799 new_id &= 0xFFF;
2800 int32_t outeyes = 0;
2801 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2802
2803 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2804 {
2805 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2806 {
2807 al_trace("Patra outer eye %d could not be created!\n",i+1);
2808
2809 for(int32_t j=0; j<i+1; j++)
2810 guys.del(guys.Count()-1);
2811
2812 return 0;
2813 }
2814 else
2815 outeyes++;
2816
2817
2818 }
2819
2820 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2821 {
2822 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2823 {
2824 al_trace("Patra inner eye %d could not be created!\n",i+1);
2825
2826 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2827 guys.del(guys.Count()-1);
2828
2829 return 0;
2830 }
2831
2832
2833 }
2834 delete ptra;
2835 break;
2836 }
2837 }
2838
2839
2840 // TODO(crash): check that the above .add succeeded.
2841 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2842 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2843 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2844 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2845 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2846 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2847 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2848 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2849 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2850 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2851 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2852 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2853
2854
2855 item_set = 0; //Do not make a drop.
2856
2857 switch(effect_type)
2858 {
2859 case -7:
2860 {
2861 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2862 Lwpns.add(w);
2863 break;
2864 }
2865 case -6:
2866 {
2867 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2868 Lwpns.add(w);
2869 break;
2870 }
2871 case -5:
2872 {
2873 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2874 Lwpns.add(w);
2875 break;
2876 }
2877 case -4:
2878 {
2879 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2880 Lwpns.add(w);
2881 break;
2882 }
2883 case -3: explode(1); break;
2884 case -2: explode(2); break;
2885 case -1: explode(0); break;
2886 case 0: break;
2887
2888 default:
2889 {
2890 //Dummy weapon function
2891 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2892 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2893 Lwpns.add(w);
2894 break;
2895 }
2896 }
2897
2898
2899 yofs = -32768;
2900 switch(guysbuf[new_id&0xFFF].family)
2901 {
2902 case eeGLEEOK:
2903 {
2904 Z_scripterrlog("Replacing a gleeok.\n");
2905 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2906 hp = -999;
2907 if (tempenemy) tempenemy->hp = -999;
2908 break;
2909
2910 }
2911 default:
2912 hp = -1000; break;
2913 }
2914 int mi = mapind(cur_map, screen_spawned);
2915 ++game->guys[mi];
2916 return 1;
2917
2918 }
2919 case edSPLIT:
2920 {
2921 for ( int32_t q = 0; q < dmisc4; q++ )
2922 {
2923 addenemy(screen_spawned,x,y,
2924 dmisc3+0x1000,-15);
2925
2926 }
2927 item_set = 0; //Do not make a drop.
2928 hp = -1000;
2929 return -1;
2930
2931 }
2932 case edSUMMON:
2933 {
2934 int32_t summon_count = zc::math::SafeMod(zc_oldrand(), dmisc4) + 1;
2935 for ( int32_t q = 0; q < summon_count; q++ )
2936 {
2937 int32_t x2=16*((zc_oldrand()%12)+2);
2938 int32_t y2=16*((zc_oldrand()%7)+2);
2939 addenemy(screen_spawned,
2940 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2941 x2,y2,
2942 dmisc3+0x1000,-15);
2943
2944 }
2945 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2946 return -1;
2947
2948 }
2949
2950 case edEXPLODESMALL:
2951 {
2952 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2953 Ewpns.add(ew);
2954 item_set = 0; //Should we make a drop?
2955 hp = -1000;
2956 return -1;
2957 }
2958
2959
2960 case edEXPLODEHARMLESS:
2961 {
2962 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2963 Ewpns.add(ew);
2964 ew->hyofs = -32768;
2965 item_set = 0; //Should we make a drop?
2966 hp = -1000;
2967 return -1;
2968 }
2969
2970
2971 case edEXPLODELARGE:
2972 {
2973 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2974 Ewpns.add(ew);
2975
2976 hp = -1000;
2977 return -1;
2978 }
2979
2980
2981 case edTRIGGERSECRETS:
2982 {
2983 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
2984 return -1;
2985 }
2986
2987 case edSTUNORCHINK:
2988
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 if(*power <= 0)
2989 {
2990 649 sfx(WAV_CHINK,pan(int32_t(x)));
2991 649 return 1;
2992 }
2993
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 1119 times.
2645 if (stunclk)
2994 {
2995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_IGNORE))
2996 return 0;
2997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_BLOCK))
2998 {
2999 sfx(WAV_CHINK,pan(int32_t(x)));
3000 return 1;
3001 }
3002 1119 }
3003 [[fallthrough]];
3004
3005 case edSTUNORIGNORE:
3006
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2502 times.
3457 if(*power <= 0)
3007 955 return 0;
3008
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 1952 times.
4454 if (stunclk)
3009 {
3010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3011 return 0;
3012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3013 {
3014 sfx(WAV_CHINK,pan(int32_t(x)));
3015 return 1;
3016 }
3017 1952 }
3018 [[fallthrough]];
3019
3020 case edSTUNONLY:
3021
7/10
✓ Branch 0 taken 4364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3817 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4043 times.
✓ Branch 9 taken 321 times.
4364 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3022 {
3023 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3024 321 return 1;
3025 }
3026
2/2
✓ Branch 0 taken 925 times.
✓ Branch 1 taken 3118 times.
4043 if (stunclk)
3027 {
3028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
3118 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3029 return 0;
3030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
3118 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3031 {
3032 sfx(WAV_CHINK,pan(int32_t(x)));
3033 return 1;
3034 }
3035 3118 }
3036 4043 stunclk=160;
3037 4043 sfx(WAV_EHIT,pan(int32_t(x)));
3038 4043 return 1;
3039
3040 case edCHINKL1:
3041 if(*power >= 1*game->get_hero_dmgmult()) break;
3042 [[fallthrough]];
3043 case edCHINKL2:
3044
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3045 [[fallthrough]];
3046 case edCHINKL4:
3047
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3048 [[fallthrough]];
3049 case edCHINKL6:
3050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3051 [[fallthrough]];
3052 case edCHINKL8:
3053
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3054 [[fallthrough]];
3055 case edCHINKL10:
3056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3057 [[fallthrough]];
3058 case edCHINK:
3059 1056 sfx(WAV_CHINK,pan(int32_t(x)));
3060 1056 return 1;
3061
3062 case edIGNOREL1:
3063 if(*power > 0) break;
3064 [[fallthrough]];
3065
3066 case edIGNORE:
3067 17349 return 0;
3068
3069 case ed1HKO:
3070 492 *power = hp;
3071 492 return -3;
3072
3073 case ed2x:
3074 {
3075
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3076 //int32_t pow = *power;
3077 //*power = vbound((pow*2),0,214747);
3078 71 return -1;
3079 }
3080 case ed3x:
3081 {
3082 *power = zc_max(1,*power*3);
3083 //int32_t pow = *power;
3084 //*power = vbound((pow*3),0,214747);
3085 return -1;
3086 }
3087
3088 case ed4x:
3089 {
3090 *power = zc_max(1,*power*4);
3091 //int32_t pow = *power;
3092 //*power = vbound((pow*4),0,214747);
3093 return -1;
3094 }
3095
3096
3097 case edHEAL:
3098 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3099 //int32_t pow = *power;
3100 //*power = vbound((pow*-1),0,214747);
3101 //break;
3102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3103 158 return -1;
3104 }
3105 /*
3106 case edLEVELDAMAGE:
3107 {
3108 int32_t pow = *power;
3109 int32_t lvl = *level;
3110 *power = vbound((pow*lvl),0,214747);
3111 break;
3112 }
3113 case edLEVELREDUCTION:
3114 {
3115 int32_t pow = *power;
3116 int32_t lvl = *level;
3117 *power = vbound((pow/lvl),0,214747);
3118 break;
3119 }
3120 */
3121
3122 case edQUARTDAMAGE:
3123
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3124
3125 [[fallthrough]];
3126 case edHALFDAMAGE:
3127
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3128 988 break;
3129
3130 case edSWITCH:
3131 {
3132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(family)
3134 {
3135 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3136 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3137 return 0;
3138 }
3139 4 hooked_comborpos = rpos_t::None;
3140 4 hooked_layerbits = 0;
3141 4 switching_object = this;
3142 4 switch_hooked = true;
3143 4 Hero.doSwitchHook(game->get_switchhookstyle());
3144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3145 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3146 4 return 1;
3147 }
3148
3149 case 0:
3150 {
3151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93607 times.
93607 if(edef == edefSwitchHook)
3152 return -1;
3153
4/4
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 74075 times.
✓ Branch 2 taken 7756 times.
✓ Branch 3 taken 11776 times.
93607 if (stunclk && *power == 0)
3154 {
3155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11776 times.
11776 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3156 return 0;
3157
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 11750 times.
11776 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3158 {
3159 26 sfx(WAV_CHINK,pan(int32_t(x)));
3160 26 return 1;
3161 }
3162 11750 }
3163 93581 break;
3164 }
3165 }
3166
3167 94744 return -1;
3168 126491 }
3169
3170 126491 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3171 {
3172
1/2
✓ Branch 0 taken 126491 times.
✗ Branch 1 not taken.
126491 int wuid = w?w->getUID():0;
3173
1/2
✓ Branch 0 taken 126491 times.
✗ Branch 1 not taken.
126491 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3174
3175
1/2
✓ Branch 0 taken 126491 times.
✗ Branch 1 not taken.
126491 if(fakeweap)
3176 Lwpns.add(w);
3177 126491 std::vector<int32_t> &ev = FFCore.eventData;
3178 126491 ev.clear();
3179 126491 ev.push_back(*power*10000);
3180 126491 ev.push_back(edef*10000);
3181 126491 ev.push_back(unblockable*10000);
3182 126491 ev.push_back(wpnId*10000);
3183 126491 ev.push_back(0);
3184 126491 ev.push_back(getUID());
3185 126491 ev.push_back(wuid);
3186
3187 126491 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3188 126491 *power = ev[0]/10000;
3189 126491 edef = ev[1]/10000;
3190 126491 unblockable = byte(ev[2]/10000);
3191 126491 wpnId = ev[3] / 10000;
3192 126491 bool nullify = ev[4]!=0;
3193 126491 ev.clear();
3194 126491 int ret = 0;
3195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126491 times.
126491 if(!nullify)
3196 {
3197 126491 ret = defendNew(wpnId, power, edef, unblockable);
3198
2/2
✓ Branch 0 taken 32388 times.
✓ Branch 1 taken 94103 times.
126491 if(ret < 0)
3199 {
3200 94103 ev.push_back(*power*10000);
3201 94103 ev.push_back(edef*10000);
3202 94103 ev.push_back(unblockable*10000);
3203 94103 ev.push_back(wpnId*10000);
3204 94103 ev.push_back(0);
3205 94103 ev.push_back(getUID());
3206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94103 times.
94103 ev.push_back(w?w->getUID():0);
3207
3208 94103 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3209 94103 *power = ev[0]/10000;
3210 94103 nullify = ev[4]!=0;
3211 94103 ev.clear();
3212 94103 }
3213 126491 }
3214
1/2
✓ Branch 0 taken 126491 times.
✗ Branch 1 not taken.
126491 if(fakeweap)
3215 Lwpns.remove(w);
3216
3217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126491 times.
126491 return nullify ? 0 : ret;
3218 }
3219
3220 99682 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3221 {
3222
2/2
✓ Branch 0 taken 99105 times.
✓ Branch 1 taken 577 times.
99682 if(!realweap) realweap = w;
3223 99682 int32_t wid = getWeaponID(w);
3224
3225 99682 int32_t edef = resolveEnemyDefence(w);
3226
2/2
✓ Branch 0 taken 6267 times.
✓ Branch 1 taken 93415 times.
99682 if(QHeader.zelda_version > 0x250)
3227 6267 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3228
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92422 times.
✗ Branch 2 not taken.
93415 switch(wid)
3229 {
3230 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3231 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3232 993 return defend(wpnId, power, edefSCRIPT);
3233
3234 case wWhistle:
3235 return -1;
3236
3237 default:
3238 92422 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3239 }
3240 99682 }
3241
3242
3243 // Check defenses without actually acting on them.
3244 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3245 {
3246
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3247 {
3248 case edSTUNONLY:
3249 474 return false;
3250 case edSTUNORCHINK:
3251 case edCHINK:
3252 15409 return unblockable&WPNUNB_BLOCK;
3253 case edSTUNORIGNORE:
3254 case edIGNORE:
3255 11050 return unblockable&WPNUNB_IGNR;
3256
3257 case edIGNOREL1:
3258 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3259 case edCHINKL1:
3260 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3261
3262 case edCHINKL2:
3263 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3264
3265 case edCHINKL4:
3266 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3267
3268 case edCHINKL6:
3269 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3270
3271 case edCHINKL8:
3272 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3273 }
3274
3275 469 return true;
3276 27402 }
3277
3278 // Do we do damage?
3279 // 0: takehit returns 0
3280 // 1: takehit returns 1
3281 // -1: do damage
3282 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3283 {
3284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3285 {
3286 switch(defense[edef])
3287 {
3288 case edIGNORE:
3289 return 0;
3290 case edIGNOREL1:
3291 case edSTUNORIGNORE:
3292 if(*power <= 0)
3293 return 0;
3294 }
3295
3296 sfx(WAV_CHINK,pan(int32_t(x)));
3297 return 1;
3298 }
3299
3300
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3301 {
3302 case edSTUNORCHINK:
3303 if(*power <= 0)
3304 {
3305 sfx(WAV_CHINK,pan(int32_t(x)));
3306 return 1;
3307 }
3308
3309 [[fallthrough]];
3310 case edSTUNORIGNORE:
3311 if(*power <= 0)
3312 return 0;
3313
3314 [[fallthrough]];
3315 case edSTUNONLY:
3316 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3317 return 1;
3318
3319 stunclk=160;
3320 sfx(WAV_EHIT,pan(int32_t(x)));
3321 return 1;
3322
3323 case edFREEZE:
3324 frozenclock=-1;
3325 //sfx(WAV_FREEZE,pan(int32_t(x)));
3326 return 1;
3327
3328 case edCHINKL1:
3329 if(*power >= 1*game->get_hero_dmgmult()) break;
3330 [[fallthrough]];
3331 case edCHINKL2:
3332 if(*power >= 2*game->get_hero_dmgmult()) break;
3333 [[fallthrough]];
3334 case edCHINKL4:
3335 if(*power >= 4*game->get_hero_dmgmult()) break;
3336 [[fallthrough]];
3337 case edCHINKL6:
3338 if(*power >= 6*game->get_hero_dmgmult()) break;
3339 [[fallthrough]];
3340 case edCHINKL8:
3341 if(*power >= 8*game->get_hero_dmgmult()) break;
3342 [[fallthrough]];
3343 case edCHINKL10:
3344 if(*power >= 10*game->get_hero_dmgmult()) break;
3345 [[fallthrough]];
3346 case edCHINK:
3347 sfx(WAV_CHINK,pan(int32_t(x)));
3348 return 1;
3349 case edTRIGGERSECRETS:
3350 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3351 break;
3352
3353 case edIGNOREL1:
3354 if(*power > 0) break;
3355 [[fallthrough]];
3356 case edIGNORE:
3357 800 return 0;
3358
3359 case ed1HKO:
3360 *power = hp;
3361 return -3;
3362
3363 case ed2x:
3364 {
3365 *power = zc_max(1,*power*2);
3366 //int32_t pow = *power;
3367 //*power = vbound((pow*2),0,214747);
3368 return -1;
3369 }
3370 case ed3x:
3371 {
3372 *power = zc_max(1,*power*3);
3373 //int32_t pow = *power;
3374 //*power = vbound((pow*3),0,214747);
3375 return -1;
3376 }
3377
3378 case ed4x:
3379 {
3380 *power = zc_max(1,*power*4);
3381 //int32_t pow = *power;
3382 //*power = vbound((pow*4),0,214747);
3383 return -1;
3384 }
3385
3386
3387 case edHEAL:
3388 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3389 //int32_t pow = *power;
3390 //*power = vbound((pow*-1),0,214747);
3391 //break;
3392 *power = zc_min(0,*power*-1);
3393 return -1;
3394 }
3395 /*
3396 case edLEVELDAMAGE:
3397 {
3398 int32_t pow = *power;
3399 int32_t lvl = *level;
3400 *power = vbound((pow*lvl),0,214747);
3401 break;
3402 }
3403 case edLEVELREDUCTION:
3404 {
3405 int32_t pow = *power;
3406 int32_t lvl = *level;
3407 *power = vbound((pow/lvl),0,214747);
3408 break;
3409 }
3410 */
3411
3412
3413 case edQUARTDAMAGE:
3414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3415
3416 [[fallthrough]];
3417 case edHALFDAMAGE:
3418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3419 7 break;
3420 }
3421
3422 193 return -1;
3423 993 }
3424
3425 // Defend against a particular item class.
3426 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3427 {
3428 int32_t def=-1;
3429
3430 switch(wpnId)
3431 {
3432 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3433 case wBrang:
3434 def = defend(wpnId, power, edefBRANG);
3435 break;
3436
3437 case wHookshot:
3438 def = defend(wpnId, power, edefHOOKSHOT);
3439 break;
3440
3441 // Anyway...
3442 case wBomb:
3443 def = defend(wpnId, power, edefBOMB);
3444 break;
3445
3446 case wSBomb:
3447 def = defend(wpnId, power, edefSBOMB);
3448 break;
3449
3450 case wArrow:
3451 def = defend(wpnId, power, edefARROW);
3452 break;
3453
3454 case wFire:
3455 def = defend(wpnId, power, edefFIRE);
3456 break;
3457
3458 case wWand:
3459 def = defend(wpnId, power, edefWAND);
3460 break;
3461
3462 case wMagic:
3463 def = defend(wpnId, power, edefMAGIC);
3464 break;
3465
3466 case wHammer:
3467 def = defend(wpnId, power, edefHAMMER);
3468 break;
3469
3470 case wSword:
3471 def = defend(wpnId, power, edefSWORD);
3472 break;
3473
3474 case wBeam:
3475 def = defend(wpnId, power, edefBEAM);
3476 break;
3477
3478 case wRefBeam:
3479 def = defend(wpnId, power, edefREFBEAM);
3480 break;
3481
3482 case wRefMagic:
3483 def = defend(wpnId, power, edefREFMAGIC);
3484 break;
3485
3486 case wRefFireball:
3487 def = defend(wpnId, power, edefREFBALL);
3488 break;
3489
3490 case wRefRock:
3491 def = defend(wpnId, power, edefREFROCK);
3492 break;
3493
3494 case wStomp:
3495 def = defend(wpnId, power, edefSTOMP);
3496 break;
3497
3498 case wCByrna:
3499 def = defend(wpnId, power, edefBYRNA);
3500 break;
3501
3502 case wScript1:
3503 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3504 else def = defend(wpnId, power, edefSCRIPT);
3505 break;
3506
3507 case wScript2:
3508 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3509 else def = defend(wpnId, power, edefSCRIPT);
3510 break;
3511
3512 case wScript3:
3513 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3514 else def = defend(wpnId, power, edefSCRIPT);
3515 break;
3516
3517 case wScript4:
3518 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3519 else def = defend(wpnId, power, edefSCRIPT);
3520 break;
3521
3522 case wScript5:
3523 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3524 else def = defend(wpnId, power, edefSCRIPT);
3525 break;
3526
3527 case wScript6:
3528 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3529 else def = defend(wpnId, power, edefSCRIPT);
3530 break;
3531
3532 case wScript7:
3533 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3534 else def = defend(wpnId, power, edefSCRIPT);
3535 break;
3536
3537 case wScript8:
3538 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3539 else def = defend(wpnId, power, edefSCRIPT);
3540 break;
3541
3542 case wScript9:
3543 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3544 else def = defend(wpnId, power, edefSCRIPT);
3545 break;
3546
3547 case wScript10:
3548 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3549 else def = defend(wpnId, power, edefSCRIPT);
3550 break;
3551
3552 case wWhistle:
3553 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3554 else break;
3555 break;
3556
3557 case wRefArrow:
3558 def = defend(wpnId, power, edefREFARROW);
3559 break;
3560 case wRefFire:
3561 def = defend(wpnId, power, edefREFFIRE);
3562 break;
3563 case wRefFire2:
3564 def = defend(wpnId, power, edefREFFIRE2);
3565 break;
3566
3567 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3568 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3569 //of the ten if the quest version is lower than N.
3570 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3571 //such as bool UseSeparatedScriptDefences. hah.
3572 default:
3573 //if(wpnId>=wScript1 && wpnId<=wScript10)
3574 // {
3575 // def = defend(wpnId, power, edefSCRIPT);
3576 // }
3577 // }
3578
3579 break;
3580 }
3581
3582 return def;
3583 }
3584
3585 // take damage or ignore it
3586 // 2 or -2: force wait a frame
3587 // < 0: damage (if any) dealt
3588 // > 0: blocked
3589 // 0: weapon passes through unhindered
3590 265280 int32_t enemy::takehit(weapon *w, weapon* realweap)
3591 {
3592
2/4
✓ Branch 0 taken 265280 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265280 times.
265280 if(fallclk||drownclk) return 0;
3593
2/2
✓ Branch 0 taken 69773 times.
✓ Branch 1 taken 195507 times.
265280 if(!realweap) realweap = w;
3594 265280 int32_t wpnId = w->id;
3595 265280 int32_t power = w->power;
3596 265280 int32_t wpnx = w->x;
3597 265280 int32_t wpny = w->y;
3598 265280 int32_t enemyHitWeapon = w->parentitem;
3599 int32_t wpnDir;
3600 265280 int32_t parent_item = w->parentitem;
3601
3602
2/2
✓ Branch 0 taken 265165 times.
✓ Branch 1 taken 115 times.
265280 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3603 {
3604 115 wpnId = w->useweapon;
3605 115 }
3606
3607 // If it's a boomerang that just bounced, use the opposite direction;
3608 // otherwise, it might bypass a shield. This probably won't handle
3609 // every case correctly, but it's better than having shields simply
3610 // not work against boomerangs.
3611
8/8
✓ Branch 0 taken 25081 times.
✓ Branch 1 taken 240199 times.
✓ Branch 2 taken 15580 times.
✓ Branch 3 taken 9501 times.
✓ Branch 4 taken 14362 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3306 times.
✓ Branch 7 taken 11056 times.
265280 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3612 11056 wpnDir = oppositeDir[w->dir];
3613 else
3614 254224 wpnDir = w->dir;
3615
3616
5/8
✓ Branch 0 taken 265280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265280 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265280 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8070 times.
✓ Branch 7 taken 272606 times.
265280 if(dying || clk<0 || hclk>0 || superman)
3617 8070 return 0;
3618
3619 //Prevent boomerang from writing to hitby[] for more than one frame.
3620 //This also prevents stunlock.
3621 //if ( stunclk > 0 ) return 0;
3622 //this needs a rule for boomerangs that cannot stunlock!
3623 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3624 //sigh.
3625
3626 272606 int32_t ret = -1;
3627
3628 // This obscure quest rule...
3629
5/6
✓ Branch 0 taken 92332 times.
✓ Branch 1 taken 180274 times.
✓ Branch 2 taken 88829 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88829 times.
272606 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3630 {
3631 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3632 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3633 3503 wpnDir=zc_oldrand()&3;
3634
3635
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3636 {
3637 189 wpnDir=down;
3638 189 }
3639
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3640 {
3641 285 wpnDir=right;
3642 285 }
3643
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3644 {
3645 2064 wpnDir=up;
3646 2064 }
3647 else
3648 {
3649 965 wpnDir=left;
3650 }
3651 3503 }
3652
3653 272606 int32_t xdir = dir;
3654 272606 shieldCanBlock=false;
3655
3656
4/4
✓ Branch 0 taken 261326 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 258559 times.
273368 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3657
6/6
✓ Branch 0 taken 18380 times.
✓ Branch 1 taken 15613 times.
✓ Branch 2 taken 26253 times.
✓ Branch 3 taken 247919 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 247811 times.
261326 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3658
4/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 246792 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 246030 times.
247811 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3659 )
3660 // The hammer should already be dealt with by subclasses (Walker etc.)
3661 {
3662
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5804 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 1488 times.
46522 switch(wpnId)
3663 {
3664 // Weapons which shields protect against
3665 case wSword:
3666 case wWand:
3667
2/2
✓ Branch 0 taken 5802 times.
✓ Branch 1 taken 2 times.
5806 if(Hero.getCharging()>0)
3668 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3669
3670 [[fallthrough]];
3671 case wHookshot:
3672 case wHSHandle:
3673 case wBrang:
3674 6184 shieldCanBlock=true;
3675 6522 break;
3676
3677 case wBeam:
3678 case wRefBeam:
3679 // Mirror shielded enemies!
3680 #if 0
3681 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3682 {
3683 if(wpnId>wEnemyWeapons)
3684 return 0;
3685
3686 sfx(WAV_CHINK,pan(int32_t(x)));
3687 return 1;
3688 }
3689
3690 #endif
3691
3692 [[fallthrough]];
3693 case wRefRock:
3694 case wRefFireball:
3695 case wMagic:
3696 #if 0
3697 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3698 {
3699 sfx(WAV_CHINK,pan(int32_t(x)));
3700 return 3;
3701 }
3702
3703 #endif
3704
3705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(wpnId>wEnemyWeapons)
3706 return 0;
3707
3708 [[fallthrough]];
3709 case wArrow:
3710 382 case wRefArrow:
3711 default:
3712 1870 shieldCanBlock=true;
3713 1870 break;
3714
3715 // Bombs
3716 case wSBomb:
3717 case wBomb:
3718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3719 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3720 {
3721 sfx(WAV_CHINK,pan(int32_t(x)));
3722 return 0;
3723 }
3724 else break;
3725
3726 // Weapons which ignore shields
3727 case wWhistle:
3728 case wHammer:
3729 153 break;
3730
3731 // Weapons which shouldn't be removed by shields
3732 case wLitBomb:
3733 case wLitSBomb:
3734 case wWind:
3735 case wPhantom:
3736 case wSSparkle:
3737 case wBait:
3738 864 return 0;
3739
3740 case wFire:
3741 case wRefFire:
3742 case wRefFire2:
3743 ;
3744 680 }
3745 8887 }
3746
3747
8/8
✓ Branch 0 taken 103219 times.
✓ Branch 1 taken 98025 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27402 times.
✓ Branch 5 taken 25035 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
266197 switch(wpnId)
3748 {
3749 case wWhistle: //No longer completely ignore whistle weapons! -Z
3750 {
3751
3752
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3753 {
3754 423 return 0; break;
3755 }
3756 else
3757 {
3758 w->power = power = itemsbuf[parent_item].misc5;
3759
3760 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3761
3762 if(def <= 0)
3763 {
3764 hp -= power;
3765 return def;
3766 }
3767 break;
3768 }
3769 break;
3770 }
3771
3772 case wPhantom:
3773 270 return 0;
3774
3775 case wLitBomb:
3776 case wLitSBomb:
3777 case wBait:
3778 case wWind:
3779 case wSSparkle:
3780 103219 return 0;
3781
3782 case wFSparkle:
3783
3784 // Only take sparkle damage if the sparkle's parent item is not
3785 // defended against.
3786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27402 times.
27402 if(enemyHitWeapon > -1)
3787 {
3788 27402 int32_t p = 0;
3789 27402 int32_t f = itemsbuf[enemyHitWeapon].family;
3790
3791
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3792 {
3793 case itype_arrow:
3794 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3795
3796 break;
3797
3798 case itype_cbyrna:
3799 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3800
3801 break;
3802
3803 case itype_brang:
3804
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3805
3806 469 break;
3807
3808 default:
3809 return 0;
3810 }
3811 469 }
3812
3813 469 wpnId = wSword;
3814 469 power = game->get_hero_dmgmult()>>1;
3815 469 goto fsparkle;
3816 break;
3817
3818 case wBrang:
3819 {
3820 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3821 25035 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3822 //preventing stunlock might be best, here. -Z
3823
2/2
✓ Branch 0 taken 5471 times.
✓ Branch 1 taken 19564 times.
25035 if(def >= 0) return def;
3824 19564 ret = def;
3825
3826 // Not hurt by 0-damage weapons
3827
2/2
✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 16380 times.
19564 if(!(flags & guy_bhit))
3828 {
3829 16380 stunclk=160;
3830
3831
3/4
✓ Branch 0 taken 16380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✓ Branch 3 taken 15069 times.
16380 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3832 {
3833
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3834 1311 goto hitclock;
3835 }
3836
3837 15069 break;
3838 }
3839
3840
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 2793 times.
3184 if(!power)
3841
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3842 else
3843 391 hp-=power;
3844
3845 3184 goto hitclock;
3846 }
3847
3848 case wHookshot:
3849 {
3850 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3851 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3852
3853
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3854 1773 ret = def;
3855
3856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3857
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3858 {
3859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3860 1625 stunclk=160;
3861
3862
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3863 {
3864
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3865 549 goto hitclock;
3866 }
3867
3868 1076 break;
3869 }
3870
3871
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3872 else
3873 45 hp-=power;
3874
3875 148 goto hitclock;
3876 }
3877 break;
3878
3879 case wHSHandle:
3880 {
3881
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3882 523 return 0;
3883
3884
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3885
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3886
3887 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3888
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3889
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3890 2177 return 0;
3891
3892 12102 power = game->get_hero_dmgmult();
3893 12571 }
3894
3895 fsparkle:
3896
3897 [[fallthrough]];
3898 default:
3899 // Work out the defenses!
3900 {
3901 99104 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3902
3903
2/2
✓ Branch 0 taken 26566 times.
✓ Branch 1 taken 72538 times.
99104 if(def >= 0)
3904 26566 return def;
3905
2/2
✓ Branch 0 taken 72078 times.
✓ Branch 1 taken 460 times.
72538 else if(def == -3) // OHKO... doesn't 'hit' the weapon?
3906 460 ret = 0;
3907 }
3908
3909
2/2
✓ Branch 0 taken 72536 times.
✓ Branch 1 taken 2 times.
145076 if(!power)
3910 {
3911
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3912 2 hp-=1;
3913 else
3914 {
3915 // Don't make a long chain of 'stun' hits
3916 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3917 return 1;
3918
3919
3920 if(!switch_hooked)
3921 stunclk=160;
3922 break;
3923 }
3924 2 }
3925 72536 else hp-=power;
3926
3927 hitclock:
3928 77741 hclk=33;
3929
3930 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3931
2/2
✓ Branch 0 taken 34731 times.
✓ Branch 1 taken 43010 times.
77741 if((dir&2)==(w->dir&2))
3932 {
3933 43010 sclk=(w->dir<<8)+16;
3934 43010 }
3935 77741 }
3936
3937
5/6
✓ Branch 0 taken 74322 times.
✓ Branch 1 taken 19564 times.
✓ Branch 2 taken 21981 times.
✓ Branch 3 taken 71905 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21981 times.
93886 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3938 {
3939 21981 fading=fade_blue_poof;
3940 21981 }
3941
3942
6/6
✓ Branch 0 taken 88602 times.
✓ Branch 1 taken 5284 times.
✓ Branch 2 taken 46937 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2347 times.
✓ Branch 5 taken 44590 times.
93886 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3943 {
3944
1/2
✓ Branch 0 taken 7631 times.
✗ Branch 1 not taken.
7631 if( hitsfx > 0 ) //user-set hit sound.
3945 {
3946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7631 times.
7631 if (!dying) //don't play the hit sound on death! -Z
3947 7631 sfx(hitsfx, pan(int32_t(x)));
3948 7631 }
3949 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3950 7631 }
3951 else //2.50.2 or earlier
3952 {
3953 86255 sfx(WAV_EHIT, pan(int32_t(x)));
3954 86255 sfx(hitsfx, pan(int32_t(x)));
3955 }
3956
2/2
✓ Branch 0 taken 93857 times.
✓ Branch 1 taken 29 times.
93886 if(family==eeGUY)
3957 29 sfx(WAV_EDEAD, pan(int32_t(x)));
3958
3959 // Penetrating weapons
3960
4/4
✓ Branch 0 taken 92012 times.
✓ Branch 1 taken 1874 times.
✓ Branch 2 taken 85106 times.
✓ Branch 3 taken 8780 times.
93886 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3961 {
3962 8780 int32_t item=enemyHitWeapon;
3963
3964
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 7168 times.
8780 if(wpnId==wArrow)
3965 {
3966 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3967
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1612 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].family == itype_arrow))
3968 379 return 0;
3969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1233 times.
1233 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3970 //if(item<0)
3971 else
3972 1233 item=current_item_id(itype_arrow);
3973 1233 }
3974
3975 else
3976 {
3977
3978 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3979
3/6
✓ Branch 0 taken 7150 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7150 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7168 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].family == itype_sword))
3980 return 0;
3981
3982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7168 times.
7168 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3983 else
3984 //if(item<0)
3985 7168 item=current_item_id(itype_sword);
3986 }
3987 8401 }
3988
3989 93507 return ret;
3990 269396 }
3991
3992 61887387 bool enemy::dont_draw()
3993 {
3994
6/6
✓ Branch 0 taken 61422874 times.
✓ Branch 1 taken 464513 times.
✓ Branch 2 taken 61351967 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 175008 times.
✓ Branch 5 taken 61247866 times.
61887387 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3995 639521 return true;
3996
3997
2/2
✓ Branch 0 taken 1371825 times.
✓ Branch 1 taken 59876041 times.
61247866 if(flags&guy_invisible)
3998 1371825 return true;
3999
4000
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59875609 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59876041 if(flags&guy_lens_only && !lensclk)
4001 return true;
4002
4003 59876041 return false;
4004 61887387 }
4005
4006 #define DRAW_NORMAL 2
4007 #define DRAW_CLOAKED 1
4008 #define DRAW_INVIS 0
4009 // base drawing function to be used by all derived classes instead of
4010 // sprite::draw()
4011 44970567 void enemy::draw(BITMAP *dest)
4012 {
4013 44970567 didScriptThisFrame = false; //Since there's no better place to put it
4014
6/6
✓ Branch 0 taken 44205435 times.
✓ Branch 1 taken 765132 times.
✓ Branch 2 taken 44122785 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 317531 times.
✓ Branch 5 taken 43887904 times.
44970567 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4015 1082663 return;
4016
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 41120239 times.
43887904 if(flags&guy_invisible)
4017 2767665 return;
4018
4019 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4020 // be cloaked if they have "invisible displays as cloaked" checked.
4021
4022 41120239 byte canSee = DRAW_NORMAL;
4023 //Enemy specific stuff
4024
2/2
✓ Branch 0 taken 41119075 times.
✓ Branch 1 taken 1164 times.
41120239 if ( editorflags & ENEMY_FLAG1 )
4025 {
4026 1164 canSee = DRAW_INVIS;
4027
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4028
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4029 {
4030 if (game->item[dmisc13])
4031 {
4032 canSee = DRAW_NORMAL;
4033 }
4034 //else if ( lensclk && getlensid.flags SHOWINVIS )
4035 //{
4036 //
4037 //}
4038 //else
4039 //{
4040 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4041 // //otherwisem invisible
4042 //}
4043 }
4044 1164 }
4045 //Room specific
4046 41120239 mapscr* scr = get_scr(screen_spawned);
4047
2/2
✓ Branch 0 taken 38949040 times.
✓ Branch 1 taken 2171199 times.
41120239 if (scr->flags3&fINVISROOM)
4048 {
4049
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4051 2171199 }
4052 //Lens check
4053
2/2
✓ Branch 0 taken 27537 times.
✓ Branch 1 taken 41092702 times.
41120239 if (lensclk)
4054 {
4055
2/2
✓ Branch 0 taken 27105 times.
✓ Branch 1 taken 432 times.
27537 if(flags&guy_lens_only)
4056 {
4057
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4058 432 }
4059 27537 }
4060 else
4061 {
4062
2/2
✓ Branch 0 taken 41019286 times.
✓ Branch 1 taken 73416 times.
41092702 if(flags&guy_lens_only)
4063 73416 canSee = DRAW_INVIS;
4064 }
4065
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 41045659 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
41120239 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4066
3/4
✓ Branch 0 taken 40819655 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40819655 times.
✗ Branch 3 not taken.
41120239 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4067
4068
2/2
✓ Branch 0 taken 41045659 times.
✓ Branch 1 taken 74580 times.
41120239 if (canSee == DRAW_INVIS)
4069 74580 return;
4070
4071
4/4
✓ Branch 0 taken 41043284 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 41043277 times.
41045659 if(fallclk||drownclk)
4072 {
4073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 if (canSee == DRAW_CLOAKED)
4074 {
4075 sprite::drawcloaked(dest);
4076 }
4077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 else if (canSee == DRAW_NORMAL)
4078 {
4079 2382 sprite::draw(dest);
4080 2382 }
4081 2382 return;
4082 }
4083 41043277 int32_t cshold=cs;
4084
4085
2/2
✓ Branch 0 taken 904137 times.
✓ Branch 1 taken 40139140 times.
41043277 if(dying)
4086 {
4087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904137 times.
904137 if(clk2>=19)
4088 {
4089 if(!(clk2&2))
4090 {
4091 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4092 if (canSee == DRAW_CLOAKED)
4093 {
4094 sprite::drawcloaked(dest);
4095 }
4096 else if (canSee == DRAW_NORMAL)
4097 {
4098 sprite::draw(dest);
4099 }
4100 }
4101 return;
4102 }
4103
4104 904137 flip = 0;
4105 904137 tile = wpnsbuf[spr_death].tile;
4106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904137 times.
904137 if ( do_animation )
4107 {
4108 904137 int32_t offs = 0;
4109
2/2
✓ Branch 0 taken 853004 times.
✓ Branch 1 taken 51133 times.
904137 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4110 {
4111
2/2
✓ Branch 0 taken 49506 times.
✓ Branch 1 taken 1627 times.
51133 if(clk2 > 2)
4112 {
4113 1627 spr_death_anim_clk=0;
4114 1627 clk2=1;
4115
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1613 times.
1627 if(hp > -1000)
4116 1613 death_sfx();
4117 1627 }
4118
4/4
✓ Branch 0 taken 38434 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 38032 times.
51133 if(clk2==1 && spr_death_anim_clk>-1)
4119 {
4120 38032 ++clk2;
4121
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35650 times.
38032 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4122
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 38011 times.
38032 spr_death_anim_frm *= zc_max(1,txsz);
4123 38032 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4124
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37956 times.
38032 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4125
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35650 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 38030 times.
✓ Branch 4 taken 36423 times.
✓ Branch 5 taken 1609 times.
38032 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4126 {
4127 1609 spr_death_anim_clk=-1;
4128 1609 clk2=1;
4129 1609 }
4130 38032 }
4131 51133 tile += spr_death_anim_frm;
4132 51133 }
4133
2/2
✓ Branch 0 taken 315607 times.
✓ Branch 1 taken 537397 times.
853004 else if(BSZ)
4134 {
4135
2/2
✓ Branch 0 taken 248172 times.
✓ Branch 1 taken 67435 times.
315607 offs = zc_min((15-clk2)/3,4);
4136 315607 }
4137
4/4
✓ Branch 0 taken 358343 times.
✓ Branch 1 taken 179054 times.
✓ Branch 2 taken 179043 times.
✓ Branch 3 taken 179300 times.
537397 else if(clk2>6 && clk2<=12)
4138 {
4139 179300 offs = 1;
4140 179300 }
4141
4142
2/2
✓ Branch 0 taken 455680 times.
✓ Branch 1 taken 448457 times.
904137 if(offs)
4143 {
4144
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 448007 times.
448457 offs *= zc_max(1,txsz);
4145 448457 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4146
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 448019 times.
448457 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4147 448457 }
4148 904137 tile += offs;
4149 904137 }
4150
4151
6/6
✓ Branch 0 taken 853004 times.
✓ Branch 1 taken 51133 times.
✓ Branch 2 taken 537397 times.
✓ Branch 3 taken 315607 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 348215 times.
904137 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4152 555922 cs = wpnsbuf[spr_death].csets&15;
4153 else
4154 348215 cs = (((clk2+5)>>1)&3)+6;
4155 904137 }
4156
3/4
✓ Branch 0 taken 1204161 times.
✓ Branch 1 taken 38934979 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1204161 times.
40139140 else if(hclk>0 && getCanFlicker())
4157 {
4158 1204161 cs = getFlashingCSet();
4159 1204161 }
4160 //draw every other frame for flickering enemies
4161
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40795246 times.
41043277 if (is_hitflickerframe(false))
4162 {
4163
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4164
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4165 {
4166 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4167 sprite_flicker_color = temp_flicker_color;
4168 sprite::draw(dest);
4169 }
4170 248031 }
4171 else
4172 {
4173
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40570084 times.
40795246 if (canSee == DRAW_CLOAKED)
4174 {
4175 225162 sprite::drawcloaked(dest);
4176 225162 }
4177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40570084 times.
40570084 else if (canSee == DRAW_NORMAL)
4178 {
4179
1/2
✓ Branch 0 taken 40570084 times.
✗ Branch 1 not taken.
40570084 if ( frozenclock < 0 )
4180 {
4181 if ( frozentile > 0 ) tile = frozentile;
4182 loadpalset(csBOSS,frozencset);
4183 }
4184 40570084 sprite::draw(dest);
4185 40570084 }
4186 }
4187 41043277 cs=cshold;
4188 44970567 }
4189
4190 //old zc bosses
4191 40940379 void enemy::drawzcboss(BITMAP *dest)
4192 {
4193 40940379 didScriptThisFrame = false; //Since there's no better place to put it
4194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40940379 times.
40940379 if(dont_draw())
4195 return;
4196
4197 40940379 int32_t cshold=cs;
4198
4199
2/2
✓ Branch 0 taken 783930 times.
✓ Branch 1 taken 40156449 times.
40940379 if(dying)
4200 {
4201
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 779970 times.
783930 if(clk2>=19)
4202 {
4203
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4204 1980 sprite::drawzcboss(dest);
4205
4206 3960 return;
4207 }
4208
4209 779970 flip = 0;
4210 779970 tile = wpnsbuf[spr_death].tile;
4211
4212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779970 times.
779970 if ( do_animation )
4213 {
4214
2/2
✓ Branch 0 taken 775454 times.
✓ Branch 1 taken 4516 times.
779970 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4215 {
4216
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4217 {
4218 6 spr_death_anim_clk=0;
4219 6 clk2=1;
4220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4221 6 death_sfx();
4222 6 }
4223
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4224 {
4225 76 ++clk2;
4226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4228 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4230
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4231 {
4232 2 spr_death_anim_clk=-1;
4233 2 clk2=1;
4234 2 }
4235 76 }
4236 4516 tile += spr_death_anim_frm;
4237 4516 }
4238
2/2
✓ Branch 0 taken 278586 times.
✓ Branch 1 taken 496868 times.
775454 else if(BSZ)
4239
2/2
✓ Branch 0 taken 219134 times.
✓ Branch 1 taken 59452 times.
278586 tile += zc_min((15-clk2)/3,4);
4240
4/4
✓ Branch 0 taken 331209 times.
✓ Branch 1 taken 165659 times.
✓ Branch 2 taken 165502 times.
✓ Branch 3 taken 165707 times.
496868 else if(clk2>6 && clk2<=12)
4241 165707 ++tile;
4242 779970 }
4243
4244
6/6
✓ Branch 0 taken 775454 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496868 times.
✓ Branch 3 taken 278586 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 312996 times.
779970 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4245 466974 cs = wpnsbuf[spr_death].csets&15;
4246 else
4247 312996 cs = (((clk2+5)>>1)&3)+6;
4248 779970 }
4249
2/2
✓ Branch 0 taken 38942083 times.
✓ Branch 1 taken 1214366 times.
40156449 else if(hclk>0)
4250 {
4251 1214366 cs = getFlashingCSet();
4252 1214366 }
4253
4254 40936419 mapscr* scr = get_scr(screen_spawned);
4255
4256
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38890800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40943962 if((scr->flags3&fINVISROOM) &&
4257
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4259 7543 lensclk) && family!=eeGANON)
4260 {
4261 7543 sprite::drawcloaked(dest);
4262 7543 }
4263 else
4264 {
4265
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40905403 times.
40928876 if (is_hitflickerframe(true))
4266 {
4267
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4268
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4269 {
4270 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4271 sprite_flicker_color = temp_flicker_color;
4272 sprite::drawzcboss(dest);
4273 }
4274 23473 }
4275 else
4276 40905403 sprite::drawzcboss(dest);
4277 }
4278
4279 40936419 cs=cshold;
4280 40940379 }
4281
4282
4283 // similar to the overblock function--can do up to a 32x32 sprite
4284 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4285 322566 void enemy::drawblock(BITMAP *dest,int32_t mask)
4286 {
4287 322566 int32_t thold=tile;
4288 322566 int32_t t1=tile;
4289 322566 int32_t t2=tile+20;
4290 322566 int32_t t3=tile+1;
4291 322566 int32_t t4=tile+21;
4292
4293
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 322566 times.
322566 switch(mask)
4294 {
4295 case 1:
4296 enemy::drawzcboss(dest);
4297 break;
4298
4299 case 3:
4300 if(flip&2)
4301 zc_swap(t1,t2);
4302
4303 tile=t1;
4304 enemy::drawzcboss(dest);
4305 tile=t2;
4306 yofs+=16;
4307 enemy::drawzcboss(dest);
4308 yofs-=16;
4309 break;
4310
4311 case 5:
4312 t2=tile+1;
4313
4314 if(flip&1)
4315 zc_swap(t1,t2);
4316
4317 tile=t1;
4318 enemy::drawzcboss(dest);
4319 tile=t2;
4320 xofs+=16;
4321 enemy::drawzcboss(dest);
4322 xofs-=16;
4323 break;
4324
4325 case 15:
4326
2/2
✓ Branch 0 taken 315810 times.
✓ Branch 1 taken 6756 times.
322566 if(flip&1)
4327 {
4328 6756 zc_swap(t1,t3);
4329 6756 zc_swap(t2,t4);
4330 6756 }
4331
4332
1/2
✓ Branch 0 taken 322566 times.
✗ Branch 1 not taken.
322566 if(flip&2)
4333 {
4334 zc_swap(t1,t2);
4335 zc_swap(t3,t4);
4336 }
4337
4338 322566 tile=t1;
4339 322566 enemy::drawzcboss(dest);
4340 322566 tile=t2;
4341 322566 yofs+=16;
4342 322566 enemy::drawzcboss(dest);
4343 322566 yofs-=16;
4344 322566 tile=t3;
4345 322566 xofs+=16;
4346 322566 enemy::drawzcboss(dest);
4347 322566 tile=t4;
4348 322566 yofs+=16;
4349 322566 enemy::drawzcboss(dest);
4350 322566 xofs-=16;
4351 322566 yofs-=16;
4352 322566 break;
4353 }
4354
4355 322566 tile=thold;
4356 322566 }
4357
4358 20383183 void enemy::drawshadow(BITMAP *dest, bool translucent)
4359 {
4360
4/4
✓ Branch 0 taken 18371837 times.
✓ Branch 1 taken 2011346 times.
✓ Branch 2 taken 526918 times.
✓ Branch 3 taken 17844919 times.
20383183 if(dont_draw() || isSideViewGravity())
4361 {
4362 2538264 return;
4363 }
4364
4365
2/2
✓ Branch 0 taken 327616 times.
✓ Branch 1 taken 17517303 times.
17844919 if(dying)
4366 {
4367 327616 return;
4368 }
4369
4370 17517303 mapscr* scr = get_scr(screen_spawned);
4371
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15799054 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17170293 times.
17517303 if(((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4372 17517303 (darkroom))
4373 {
4374 347010 return;
4375 }
4376 else
4377 {
4378
4/4
✓ Branch 0 taken 16571138 times.
✓ Branch 1 taken 599155 times.
✓ Branch 2 taken 16523670 times.
✓ Branch 3 taken 47468 times.
17170293 if(enemycanfall(id, false) && shadowtile == 0)
4379 47468 shadowtile = wpnsbuf[spr_shadow].tile;
4380
4381
5/6
✓ Branch 0 taken 16226411 times.
✓ Branch 1 taken 943882 times.
✓ Branch 2 taken 16226411 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15627256 times.
✓ Branch 5 taken 599155 times.
17170293 if(z>0 || fakez>0 || !enemycanfall(id, false))
4382 {
4383
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1542762 times.
1543037 if(!shadow_overpit(this))
4384 1542762 sprite::drawshadow(dest,translucent);
4385 1543037 }
4386 }
4387 20383183 }
4388
4389 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4390 {
4391 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4392
4393
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4394 {
4395 129181 xofs-=mx;
4396 129181 yofs-=my;
4397 129181 enemy::draw(sub);
4398 129181 xofs+=mx;
4399 129181 yofs+=my;
4400 129181 destroy_bitmap(sub);
4401 129181 }
4402 else
4403 enemy::draw(dest);
4404 129181 }
4405
4406 9 void enemy::init_size_flags()
4407 {
4408
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4409
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4410
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4411
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4413
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4414
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4415
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4416
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4417 {
4418 yofs = (int32_t)d->yofs;
4419 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4420 }
4421
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4422 9 }
4423
4424 // override hit detection to check for invicibility, stunned, etc
4425 112657969 bool enemy::hit()
4426 {
4427
4/4
✓ Branch 0 taken 111330887 times.
✓ Branch 1 taken 1327082 times.
✓ Branch 2 taken 109516341 times.
✓ Branch 3 taken 1814546 times.
112657969 if(dying || hclk>0) return false;
4428 109516341 return sprite::hit();
4429 112657969 }
4430 730351 bool enemy::hit(sprite *s)
4431 {
4432
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4433 713374 return sprite::hit(s);
4434 730351 }
4435
4436 44720726 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4437 {
4438
2/2
✓ Branch 0 taken 3972954 times.
✓ Branch 1 taken 40747772 times.
44720726 if(!hit()) return false;
4439 40747772 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4440 44720726 }
4441 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4442 {
4443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4444 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4445 78011 }
4446
4447 11190302 bool enemy::hit(weapon *w)
4448 {
4449
2/2
✓ Branch 0 taken 1196268 times.
✓ Branch 1 taken 9994034 times.
11190302 if(!hit()) return false;
4450
4451
2/2
✓ Branch 0 taken 6647382 times.
✓ Branch 1 taken 3346652 times.
9994034 if (replay_version_check(0, 14))
4452 {
4453
4/6
✓ Branch 0 taken 6422331 times.
✓ Branch 1 taken 225051 times.
✓ Branch 2 taken 6422331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6422331 times.
✗ Branch 5 not taken.
6647382 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4454 225051 return false;
4455 6422331 return sprite::hit(w);
4456 }
4457 3346652 return w->hit(this);
4458 11190302 }
4459
4460 9488738 bool enemy::can_pitfall(bool checkspawning)
4461 {
4462
4/4
✓ Branch 0 taken 9468807 times.
✓ Branch 1 taken 19931 times.
✓ Branch 2 taken 9458152 times.
✓ Branch 3 taken 30586 times.
9488738 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4463
2/2
✓ Branch 0 taken 9440456 times.
✓ Branch 1 taken 17696 times.
9458152 switch(guysbuf[id&0xFFF].family)
4464 {
4465 case eeAQUA:
4466 case eeDIG:
4467 case eeDONGO:
4468 case eeFAIRY:
4469 case eeGANON:
4470 case eeGHOMA:
4471 case eeGLEEOK:
4472 case eeGUY:
4473 case eeLANM:
4474 case eeMANHAN:
4475 case eeMOLD:
4476 case eeNONE:
4477 case eePATRA:
4478 case eeZORA:
4479 17696 return false; //Disallowed types
4480 default:
4481 9440456 return true;
4482 }
4483 9488738 }
4484 //Handle death
4485 38007133 void enemy::try_death(bool force_kill)
4486 {
4487
8/8
✓ Branch 0 taken 37950564 times.
✓ Branch 1 taken 56569 times.
✓ Branch 2 taken 37950553 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43643 times.
✓ Branch 5 taken 37906910 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43642 times.
38007133 if(!dying && (force_kill || (hp<=0 && !immortal)))
4488 {
4489 43653 std::vector<int32_t> &ev = FFCore.eventData;
4490 43653 ev.clear();
4491 43653 ev.push_back(10000);
4492 43653 ev.push_back(getUID());
4493
4494 43653 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4495 43653 bool isSaved = !ev[0];
4496 43653 ev.clear();
4497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43653 times.
43653 if(isSaved) return;
4498
4499
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 43603 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 44 times.
43653 if (itemguy && get_screen_state(screen_spawned).item_state == ScreenItemState::CarriedByEnemy)
4500 {
4501
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 44 times.
95 for(int32_t i=0; i<items.Count(); i++)
4502 {
4503
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 44 times.
51 if(((item*)items.spr(i))->pickup&ipENEMY && screen_spawned == ((item*)items.spr(i))->screen_spawned)
4504 {
4505
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4506 {
4507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4508 {
4509 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4510 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4511 }
4512 else
4513 {
4514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(extend >= 3)
4515 {
4516 items.spr(i)->x = x+(txsz-1)*8;
4517 items.spr(i)->y = y-2+(tysz-1)*8;
4518 }
4519 else
4520 {
4521 3 items.spr(i)->x = x;
4522 3 items.spr(i)->y = y - 2;
4523 }
4524 }
4525 3 items.spr(i)->z = z;
4526 3 items.spr(i)->fakez = fakez;
4527 3 }
4528 else
4529 {
4530 41 items.spr(i)->x = x;
4531 41 items.spr(i)->y = y - 2;
4532 }
4533 44 }
4534 51 }
4535 44 }
4536
4537 43653 dying=true;
4538
4539
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43621 times.
43653 if(fading==fade_flash_die)
4540 32 clk2=19+18*4;
4541 else
4542 {
4543 43621 clk2 = BSZ ? 15 : 19;
4544
4545
2/2
✓ Branch 0 taken 21061 times.
✓ Branch 1 taken 22560 times.
43621 if(fading!=fade_blue_poof)
4546 22560 fading=0;
4547 }
4548
4549
2/2
✓ Branch 0 taken 43603 times.
✓ Branch 1 taken 50 times.
43653 if(itemguy)
4550 {
4551 50 screen_item_set_state(screen_spawned, ScreenItemState::None);
4552 50 item_set=0;
4553 50 }
4554
6/6
✓ Branch 0 taken 42599 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33918 times.
✓ Branch 3 taken 8681 times.
✓ Branch 4 taken 1428 times.
✓ Branch 5 taken 32490 times.
43653 if (screen_spawned < 128 && count_enemy && !script_spawned)
4555 32490 game->guys[mapind(cur_map, screen_spawned)] -= 1;
4556 43653 }
4557 38007133 }
4558
4559 // --==**==--
4560
4561 // Movement routines that can be used by derived classes as needed
4562
4563 // --==**==--
4564
4565 556472 void enemy::fix_coords(bool bound)
4566 {
4567
1/2
✓ Branch 0 taken 556472 times.
✗ Branch 1 not taken.
556472 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4568
1/2
✓ Branch 0 taken 556472 times.
✗ Branch 1 not taken.
556472 if(moveflags & move_ignore_screenedge) bound = false;
4569
4570
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474792 times.
556472 if(bound)
4571 {
4572 474792 int w = world_w;
4573 474792 int h = world_h;
4574
4575
1/2
✓ Branch 0 taken 474792 times.
✗ Branch 1 not taken.
474792 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4576 {
4577
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474790 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474792 x=vbound(x, 0, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (w-((txsz-1)*16)) : w-16));
4578
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474790 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474792 y=vbound(y, 0,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (h-((txsz-1)*16)) : h-16));
4579 474792 }
4580 else
4581 {
4582 x=vbound(x, 0, w-16);
4583 y=vbound(y, 0, h-16);
4584 }
4585 474792 }
4586
4587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556472 times.
556472 if(!OUTOFBOUNDS(id, x, y))
4588 {
4589 556472 do_fix(x, 16, true);
4590
2/2
✓ Branch 0 taken 1139 times.
✓ Branch 1 taken 555333 times.
556472 if(isSideViewGravity())
4591 1139 do_fix(y,8,true);
4592 555333 else do_fix(y,16,true);
4593 556472 }
4594 556472 }
4595 9176 bool enemy::cannotpenetrate()
4596 {
4597
4/4
✓ Branch 0 taken 8995 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8957 times.
9176 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4598 }
4599
4600 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4601 {
4602 bool ok;
4603 562 int32_t dx = 0, dy = 0;
4604 562 int32_t sv = 8;
4605
4606 //Why is this here??? Why is it needed???
4607 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4608
4609
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4610 {
4611 case 8:
4612 case up:
4613
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4614 return false;
4615
4616 69 dy = dy1-s;
4617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4619 69 break;
4620
4621 case 12:
4622 case down:
4623
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4624 return false;
4625
4626 51 dy = dy2+s;
4627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4628 51 break;
4629
4630 case 14:
4631 case left:
4632 47 dx = dx1-s;
4633 47 sv = ((isSideViewGravity())?7:8);
4634
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4635
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4636 47 break;
4637
4638 case 10:
4639 case right:
4640 85 dx = dx2+s;
4641 85 sv = ((isSideViewGravity())?7:8);
4642
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4643 85 break;
4644
4645 case 9:
4646 case r_up:
4647 94 dx = dx2+s;
4648 94 dy = dy1-s;
4649
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4651 94 break;
4652
4653 case 11:
4654 case r_down:
4655 78 dx = dx2+s;
4656 78 dx = dy2+s;
4657
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4659 78 break;
4660
4661 case 13:
4662 case l_down:
4663 57 dx = dx1-s;
4664 57 dy = dy2+s;
4665
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4667 57 break;
4668
4669 case 15:
4670 case l_up:
4671 81 dx = dx1-s;
4672 81 dy = dy1-s;
4673
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4675 81 break;
4676
4677 default:
4678 db=99;
4679 return true;
4680 }
4681
4682 562 return ok;
4683 562 }
4684
4685
4686
4687
4688 // returns true if next step is ok, false if there is something there
4689 7359866 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4690 {
4691 7359866 bool ok = false; //initialise the var, son't just declare it
4692 7359866 int32_t dx = 0, dy = 0;
4693 7359866 int32_t sv = 8;
4694 7359866 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4695 //Why is this here??? Why is it needed???
4696 7359866 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7359866 times.
7359866 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7359866 times.
7359866 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4699
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7359853 times.
7359866 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4700
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7359853 times.
7359866 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4701 7359866 bool offgrid = OFFGRID_ENEMY;
4702
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7352575 times.
7359866 if(!offgrid)
4703 {
4704 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4705
1/2
✓ Branch 0 taken 7352575 times.
✗ Branch 1 not taken.
7352575 if(usehei<16)usehei=16;
4706
1/2
✓ Branch 0 taken 7352575 times.
✗ Branch 1 not taken.
7352575 if(usewid<16)usewid=16;
4707 7352575 }
4708
9/9
✓ Branch 0 taken 1331292 times.
✓ Branch 1 taken 1107702 times.
✓ Branch 2 taken 1227733 times.
✓ Branch 3 taken 1218302 times.
✓ Branch 4 taken 540601 times.
✓ Branch 5 taken 642269 times.
✓ Branch 6 taken 603863 times.
✓ Branch 7 taken 568437 times.
✓ Branch 8 taken 119667 times.
7359866 switch(ndir) //need to check every 8 pixels between two points
4709 {
4710 case 8:
4711 case up:
4712 {
4713
4/4
✓ Branch 0 taken 150801 times.
✓ Branch 1 taken 1180491 times.
✓ Branch 2 taken 150141 times.
✓ Branch 3 taken 660 times.
1331292 if(enemycanfall(id) && isSideViewGravity())
4714 660 return false;
4715
4716 1330632 dy = dy1-s;
4717
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1330152 times.
1330632 special = (special==spw_clipbottomright)?spw_none:special;
4718 1330632 tries = usewid/(offgrid ? 8 : 16);
4719
4720
2/2
✓ Branch 0 taken 1130420 times.
✓ Branch 1 taken 1331282 times.
2461702 for ( ; tries > 0; --tries )
4721 {
4722
2/2
✓ Branch 0 taken 197588 times.
✓ Branch 1 taken 1133694 times.
1331282 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4723 1331282 try_x += (offgrid ? 8 : 16);
4724
2/2
✓ Branch 0 taken 1131070 times.
✓ Branch 1 taken 200212 times.
1331282 if (!ok) break;
4725 1131070 }
4726
2/2
✓ Branch 0 taken 1130420 times.
✓ Branch 1 taken 200212 times.
1330632 if(!ok) break;
4727
1/2
✓ Branch 0 taken 1130420 times.
✗ Branch 1 not taken.
1130420 if((usewid%16)>0) //Uneven width
4728 {
4729 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4730 }
4731 1130420 break;
4732 }
4733 case 12:
4734 case down:
4735 {
4736
4/4
✓ Branch 0 taken 180675 times.
✓ Branch 1 taken 927027 times.
✓ Branch 2 taken 179949 times.
✓ Branch 3 taken 726 times.
1107702 if(enemycanfall(id) && isSideViewGravity())
4737 726 return false;
4738
4739 1106976 dy = dy2+s;
4740 1106976 tries = usewid/(offgrid ? 8 : 16);
4741
2/2
✓ Branch 0 taken 900625 times.
✓ Branch 1 taken 1107760 times.
2008385 for ( ; tries > 0; --tries )
4742 {
4743
3/4
✓ Branch 0 taken 205603 times.
✓ Branch 1 taken 902157 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 902157 times.
1107760 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4744 1107760 try_x += (offgrid ? 8 : 16);
4745
2/2
✓ Branch 0 taken 901409 times.
✓ Branch 1 taken 206351 times.
1107760 if (!ok) break;
4746 901409 }
4747
2/2
✓ Branch 0 taken 900625 times.
✓ Branch 1 taken 206351 times.
1106976 if(!ok) break;
4748
1/2
✓ Branch 0 taken 900625 times.
✗ Branch 1 not taken.
900625 if((usewid%16)>0) //Uneven width
4749 {
4750 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4751 }
4752 900625 break;
4753 }
4754 case 14:
4755 case left:
4756 {
4757 1227733 dx = dx1-s;
4758 1227733 sv = ((isSideViewGravity())?7:0);
4759
4/4
✓ Branch 0 taken 1227110 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1225342 times.
1227733 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4760 1227733 tries = usehei/(offgrid ? 8 : 16);
4761
2/2
✓ Branch 0 taken 1028528 times.
✓ Branch 1 taken 1228650 times.
2257178 for ( ; tries > 0; --tries )
4762 {
4763
2/2
✓ Branch 0 taken 198020 times.
✓ Branch 1 taken 1030630 times.
1228650 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4764 1228650 try_y += (offgrid ? 8 : 16);
4765
2/2
✓ Branch 0 taken 1029445 times.
✓ Branch 1 taken 199205 times.
1228650 if (!ok) break;
4766 1029445 }
4767
2/2
✓ Branch 0 taken 1028528 times.
✓ Branch 1 taken 199205 times.
1227733 if(!ok) break;
4768
1/2
✓ Branch 0 taken 1028528 times.
✗ Branch 1 not taken.
1028528 if((usehei%16)>0) //Uneven height
4769 {
4770 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4771 }
4772 1028528 break;
4773 }
4774 case 10:
4775 case right:
4776 {
4777 1218302 dx = dx2+s;
4778 1218302 sv = ((isSideViewGravity())?7:0);
4779 1218302 tries = usehei/(offgrid ? 8 : 16);
4780
2/2
✓ Branch 0 taken 1029990 times.
✓ Branch 1 taken 1219196 times.
2249186 for ( ; tries > 0; --tries )
4781 {
4782
3/4
✓ Branch 0 taken 186957 times.
✓ Branch 1 taken 1032239 times.
✓ Branch 2 taken 1032239 times.
✗ Branch 3 not taken.
1219196 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4783 1219196 try_y += (offgrid ? 8 : 16);
4784
2/2
✓ Branch 0 taken 1030884 times.
✓ Branch 1 taken 188312 times.
1219196 if (!ok) break;
4785 1030884 }
4786
2/2
✓ Branch 0 taken 1029990 times.
✓ Branch 1 taken 188312 times.
1218302 if(!ok) break;
4787
1/2
✓ Branch 0 taken 1029990 times.
✗ Branch 1 not taken.
1029990 if((usehei%16)>0) //Uneven height
4788 {
4789 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4790 }
4791 1029990 break;
4792 }
4793 case 9:
4794 case r_up:
4795 {
4796 540601 dx = dx2+s;
4797 540601 dy = dy1-s;
4798 540601 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4799 540601 sv = ((isSideViewGravity())?7:0);
4800
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_x > 0; --tries_x )
4801 {
4802 540601 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4803 540601 try_y = 0;
4804
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_y > 0; --tries_y )
4805 {
4806
4/4
✓ Branch 0 taken 532330 times.
✓ Branch 1 taken 8271 times.
✓ Branch 2 taken 526882 times.
✓ Branch 3 taken 5448 times.
1067483 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4807
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 524490 times.
526882 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4808 540601 try_y += (offgrid ? 8 : 16);
4809
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4810 523541 }
4811
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523541 times.
523541 if((usehei%16)>0) //Uneven height
4813 {
4814 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4815 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4816 }
4817 523541 try_x += (offgrid ? 8 : 16);
4818 523541 }
4819
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if(!ok) break;
4820
1/2
✓ Branch 0 taken 523541 times.
✗ Branch 1 not taken.
523541 if((usewid%16)>0) //Uneven width
4821 {
4822 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4823 try_y = 0;
4824 for ( ; tries_y > 0; --tries_y )
4825 {
4826 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4827 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4828 try_y += (offgrid ? 8 : 16);
4829 if (!ok) break;
4830 }
4831 if (!ok) break;
4832 if((usehei%16)>0) //Uneven height
4833 {
4834 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4835 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4836 }
4837 }
4838 523541 break;
4839 }
4840 case 11:
4841 case r_down:
4842 {
4843 642269 dx = dx2+s;
4844 642269 dx = dy2+s;
4845 642269 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4846 //sv = ((isSideViewGravity())?7:0);
4847
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_x > 0; --tries_x )
4848 {
4849 642269 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4850 642269 try_y = 0;
4851
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_y > 0; --tries_y )
4852 {
4853
4/4
✓ Branch 0 taken 640758 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 627938 times.
✓ Branch 3 taken 12820 times.
1270207 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4854
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 627832 times.
627938 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4855 642269 try_y += (offgrid ? 8 : 16);
4856
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4857 626871 }
4858
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626871 times.
626871 if((usehei%16)>0) //Uneven height
4860 {
4861 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4862 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4863 }
4864 626871 try_x += (offgrid ? 8 : 16);
4865 626871 }
4866
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if(!ok) break;
4867
1/2
✓ Branch 0 taken 626871 times.
✗ Branch 1 not taken.
626871 if((usewid%16)>0) //Uneven width
4868 {
4869 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4870 try_y = 0;
4871 for ( ; tries_y > 0; --tries_y )
4872 {
4873 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4874 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4875 try_y += (offgrid ? 8 : 16);
4876 if (!ok) break;
4877 }
4878 if (!ok) break;
4879 if((usehei%16)>0) //Uneven height
4880 {
4881 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4882 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4883 }
4884 }
4885 626871 break;
4886 }
4887 case 13:
4888 case l_down:
4889 {
4890 603863 dx = dx1-s;
4891 603863 dy = dy2+s;
4892 603863 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4893 //sv = ((isSideViewGravity())?7:0);
4894
2/2
✓ Branch 0 taken 586787 times.
✓ Branch 1 taken 603863 times.
1190650 for ( ; tries_x > 0; --tries_x )
4895 {
4896 603863 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4897 603863 try_y = 0;
4898
2/2
✓ Branch 0 taken 586787 times.
✓ Branch 1 taken 603863 times.
1190650 for ( ; tries_y > 0; --tries_y )
4899 {
4900
4/4
✓ Branch 0 taken 591929 times.
✓ Branch 1 taken 11934 times.
✓ Branch 2 taken 587655 times.
✓ Branch 3 taken 4274 times.
1191518 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4901
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 587087 times.
587655 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4902 603863 try_y += (offgrid ? 8 : 16);
4903
2/2
✓ Branch 0 taken 586787 times.
✓ Branch 1 taken 17076 times.
603863 if (!ok) break;
4904 586787 }
4905
2/2
✓ Branch 0 taken 586787 times.
✓ Branch 1 taken 17076 times.
603863 if (!ok) break;
4906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586787 times.
586787 if((usehei%16)>0) //Uneven height
4907 {
4908 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4909 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4910 }
4911 586787 try_x += (offgrid ? 8 : 16);
4912 586787 }
4913
2/2
✓ Branch 0 taken 586787 times.
✓ Branch 1 taken 17076 times.
603863 if(!ok) break;
4914
1/2
✓ Branch 0 taken 586787 times.
✗ Branch 1 not taken.
586787 if((usewid%16)>0) //Uneven width
4915 {
4916 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4917 try_y = 0;
4918 for ( ; tries_y > 0; --tries_y )
4919 {
4920 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4921 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4922 try_y += (offgrid ? 8 : 16);
4923 if (!ok) break;
4924 }
4925 if (!ok) break;
4926 if((usehei%16)>0) //Uneven height
4927 {
4928 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4929 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4930 }
4931 }
4932 586787 break;
4933 }
4934 case 15:
4935 case l_up:
4936 {
4937 568437 dx = dx1-s;
4938 568437 dy = dy1-s;
4939 568437 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4940 568437 sv = ((isSideViewGravity())?7:0);
4941
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_x > 0; --tries_x )
4942 {
4943 568437 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4944 568437 try_y = 0;
4945
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_y > 0; --tries_y )
4946 {
4947
4/4
✓ Branch 0 taken 559771 times.
✓ Branch 1 taken 8666 times.
✓ Branch 2 taken 555802 times.
✓ Branch 3 taken 3969 times.
1124239 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4948
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 553363 times.
555802 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4949 568437 try_y += (offgrid ? 8 : 16);
4950
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4951 552494 }
4952
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552494 times.
552494 if((usehei%16)>0) //Uneven height
4954 {
4955 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4956 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4957 }
4958 552494 try_x += (offgrid ? 8 : 16);
4959 552494 }
4960
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if(!ok) break;
4961
1/2
✓ Branch 0 taken 552494 times.
✗ Branch 1 not taken.
552494 if((usewid%16)>0) //Uneven width
4962 {
4963 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4964 try_y = 0;
4965 for ( ; tries_y > 0; --tries_y )
4966 {
4967 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4968 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4969 try_y += (offgrid ? 8 : 16);
4970 if (!ok) break;
4971 }
4972 if (!ok) break;
4973 if((usehei%16)>0) //Uneven height
4974 {
4975 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4976 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4977 }
4978 }
4979 552494 break;
4980 }
4981 default:
4982 119667 db=99;
4983 119667 return true;
4984 }
4985
4986 7238813 return ok;
4987 7359866 }
4988
4989
4990 4652343 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4991 {
4992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652343 times.
4652343 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652343 times.
4652343 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4994
1/2
✓ Branch 0 taken 4652343 times.
✗ Branch 1 not taken.
4652343 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4995
1/2
✓ Branch 0 taken 4652343 times.
✗ Branch 1 not taken.
4652343 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4996 4652343 --usewid;
4997 4652343 --usehei;
4998 4652343 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4999 }
5000
5001 1244746 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5002 {
5003 1244746 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5004
5005
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1237927 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1244746 if(special==spw_clipright&&ndir==right)
5006 {
5007 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5008 1798 }
5009
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244741 times.
1244746 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5010
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244741 times.
1244746 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5011
1/2
✓ Branch 0 taken 1244746 times.
✗ Branch 1 not taken.
1244746 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5012
1/2
✓ Branch 0 taken 1244746 times.
✗ Branch 1 not taken.
1244746 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5013 1244746 --usewid;
5014 1244746 --usehei;
5015
2/2
✓ Branch 0 taken 717798 times.
✓ Branch 1 taken 526948 times.
1244746 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5016 }
5017
5018 136347 bool enemy::canmove(int32_t ndir, bool kb)
5019 {
5020 136347 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5021 }
5022
5023 // 8-directional
5024 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5025 {
5026 562 int32_t ndir=0;
5027
5028 // can move straight, check if it wants to turn
5029
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5030 {
5031
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5032 {
5033 int32_t w = Lwpns.idFirst(wBait);
5034
5035 if(w>=0)
5036 {
5037 int32_t bx = Lwpns.spr(w)->x;
5038 int32_t by = Lwpns.spr(w)->y;
5039
5040 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5041
5042 if(abs(int32_t(y)-by)>14)
5043 {
5044 if(ndir>0) // Already left or right
5045 {
5046 // Making the diagonal directions
5047 ndir += (by<y) ? 2 : 4;
5048 }
5049 else
5050 {
5051 ndir = (by<y) ? up : down;
5052 }
5053 }
5054
5055 if(canmove(ndir,special,false))
5056 {
5057 dir=ndir;
5058 return;
5059 }
5060 }
5061 }
5062
5063 // Homing added.
5064
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5065 {
5066 ndir = lined_up(8,true);
5067
5068 if(ndir>=0 && canmove(ndir,special,false))
5069 {
5070 dir=ndir;
5071 }
5072
5073 return;
5074 }
5075
5076 549 int32_t r=zc_oldrand();
5077
5078
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5079 {
5080 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5081 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5082
5083
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5084 525 dir=ndir;
5085
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5086 19 dir=ndir2;
5087
5088
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5089 // due to numerous lost fractional components. -L
5090 {
5091 x.doFloor();
5092 y.doFloor();
5093 }
5094 549 }
5095
5096 549 return;
5097 }
5098
5099 // can't move straight, must turn
5100 13 int32_t i=0;
5101
5102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5103 {
5104 20 ndir=(zc_oldrand()&7)+8;
5105
5106
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5107 13 break;
5108 7 }
5109
5110
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5111 {
5112 for(ndir=8; ndir<16; ndir++)
5113 {
5114 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5115 goto ok;
5116 }
5117
5118 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5119 }
5120
5121 ok:
5122 13 dir=ndir;
5123 13 x.doFloor();
5124 13 y.doFloor();
5125 562 }
5126
5127 580727 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5128 {
5129 580727 int32_t ndir=0;
5130
5131 // can move straight, check if it wants to turn
5132
2/2
✓ Branch 0 taken 548064 times.
✓ Branch 1 taken 32663 times.
580727 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5133 {
5134
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 547857 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
548064 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5135 {
5136 101 int32_t i = Lwpns.idFirst(wBait);
5137
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5138 {
5139 weapon *w = (weapon*)Lwpns.spr(i);
5140 if (get_qr(qr_FIND_CLOSEST_BAIT))
5141 {
5142 int32_t currentrange;
5143 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5144 else currentrange = -1;
5145 int curid = i;
5146 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5147 for(; i<Lwpns.Count(); ++i)
5148 {
5149 weapon *lw = (weapon*)Lwpns.spr(i);
5150 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5151 {
5152 currentrange = distance(x, y, lw->x, lw->y);
5153 curid = i;
5154 }
5155 }
5156 i = curid;
5157 if (currentrange == -1) i = -1;
5158 }
5159 else
5160 {
5161 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5162 }
5163 if(i>=0)
5164 {
5165 int32_t bx = Lwpns.spr(i)->x;
5166 int32_t by = Lwpns.spr(i)->y;
5167
5168 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5169
5170 if(abs(int32_t(y)-by)>14)
5171 {
5172 if(ndir>0) // Already left or right
5173 {
5174 // Making the diagonal directions
5175 ndir += (by<y) ? 2 : 4;
5176 }
5177 else
5178 {
5179 ndir = (by<y) ? up : down;
5180 }
5181 }
5182 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5183 if(canmove(ndir,special,false))
5184 {
5185 dir=ndir;
5186 return;
5187 }
5188 }
5189 }
5190 101 }
5191
5192 // Homing added.
5193
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 518438 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
548064 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5194 {
5195 14216 ndir = lined_up(8,true);
5196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5197
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5198 {
5199 5852 dir=ndir;
5200 5852 }
5201
5202 14216 return;
5203 }
5204
5205 533848 int32_t r=zc_oldrand();
5206
5207
4/4
✓ Branch 0 taken 340047 times.
✓ Branch 1 taken 193801 times.
✓ Branch 2 taken 179766 times.
✓ Branch 3 taken 160281 times.
533848 if(newrate>0 && !(r%newrate))
5208 {
5209 160281 ndir = ((dir+((r&64)?-1:1))&7)+8;
5210 160281 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5211
5212
2/2
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
160281 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5213 154477 dir=ndir;
5214
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4947 times.
5804 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5215 4947 dir=ndir2;
5216
5217
4/4
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
✓ Branch 2 taken 147151 times.
✓ Branch 3 taken 7326 times.
160281 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5218 // due to numerous lost fractional components. -L
5219 {
5220 7326 x.doFloor();
5221 7326 y.doFloor();
5222 7326 }
5223 160281 }
5224
5225 533848 return;
5226 }
5227
5228 // can't move straight, must turn
5229 32663 int32_t i=0;
5230
5231 // TODO: speed this up!
5232
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 61154 times.
61224 for(; i<32; i++) // Try random dir
5233 {
5234 61154 ndir=(zc_oldrand()&7)+8;
5235
5236
2/2
✓ Branch 0 taken 28561 times.
✓ Branch 1 taken 32593 times.
61154 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5237 32593 break;
5238 28561 }
5239
5240
2/2
✓ Branch 0 taken 32593 times.
✓ Branch 1 taken 70 times.
32716 if(i==32)
5241 {
5242
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5243 {
5244
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5245 17 goto ok;
5246 444 }
5247
5248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5249 53 }
5250
5251 ok:
5252 32663 dir=ndir;
5253 32663 x.doFloor();
5254 32663 y.doFloor();
5255 580727 }
5256
5257 574252 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5258 {
5259 574252 newdir_8(newrate,newhoming,special,0,-8,15,15);
5260 574252 }
5261
5262 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5263 {
5264 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5265 562 }
5266
5267 // makes the enemy slide backwards when hit
5268 // sclk: first byte is clk, second byte is dir
5269 // makes the enemy slide backwards when hit
5270 // sclk: first byte is clk, second byte is dir
5271 15644617 int32_t enemy::slide()
5272 {
5273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15644617 times.
15644617 if(script_knockback_clk!=0) //scripted knockback
5274 {
5275 sclk = 0;
5276 return 1; //scripted knockback ran
5277 }
5278
5/6
✓ Branch 0 taken 102113 times.
✓ Branch 1 taken 15542504 times.
✓ Branch 2 taken 7857 times.
✓ Branch 3 taken 94256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7857 times.
15644617 if(sclk==0 || (hp<=0 && !immortal))
5279 15550361 return 0;
5280
5281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94256 times.
94256 if(knockbackflags & FLAG_NOSLIDE)
5282 {
5283 sclk = 0;
5284 if(!OFFGRID_ENEMY)
5285 {
5286 //Fix to grid
5287 do_fix(x, 16, true);
5288 do_fix(y, 16, true);
5289 }
5290 return 0;
5291 }
5292
8/10
✓ Branch 0 taken 9554 times.
✓ Branch 1 taken 84702 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 9256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 298 times.
✓ Branch 6 taken 7103 times.
✓ Branch 7 taken 2153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 298 times.
94256 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5293 {
5294 2153 sclk=0;
5295 2153 return 0;
5296 }
5297
5298 92103 --sclk;
5299
5300
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35754 times.
92103 switch(sclk>>8)
5301 {
5302 case up:
5303 {
5304
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5305 {
5306 7 sclk=0;
5307 7 return 0;
5308 }
5309
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5310
5311 10357 break;
5312 }
5313 case down:
5314 {
5315
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5316 {
5317 2 sclk=0;
5318 2 return 0;
5319 }
5320
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5321
5322 12143 break;
5323 }
5324 case left:
5325 {
5326
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5327 {
5328 13 sclk=0;
5329 13 return 0;
5330 }
5331
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5332
5333 31483 break;
5334 }
5335 case right:
5336 {
5337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35754 times.
35754 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5338 {
5339 sclk=0;
5340 return 0;
5341 }
5342
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32466 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35754 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5343 35484 break;
5344 }
5345 }
5346
5347 91252 int32_t move = knockbackSpeed;
5348
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 91252 times.
177621 while(move>0)
5349 {
5350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91252 times.
91252 int32_t thismove = zc_min(8, move);
5351 91252 move -= thismove;
5352 91252 hitdir = (sclk>>8);
5353
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35484 times.
91252 switch(sclk>>8)
5354 {
5355 case up:
5356 10357 y-=thismove;
5357 10357 break;
5358
5359 case down:
5360 12143 y+=thismove;
5361 12143 break;
5362
5363 case left:
5364 31483 x-=thismove;
5365 31483 break;
5366
5367 case right:
5368 35484 x+=thismove;
5369 35484 break;
5370 }
5371
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 4883 times.
91252 if(!canmove(sclk>>8,(zfix)0,0,true))
5372 {
5373
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2906 times.
✓ Branch 2 taken 4 times.
4883 switch(sclk>>8)
5374 {
5375 case up:
5376 case down:
5377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5378 y = 0;
5379
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5380 325 y = TRUNCATE_TILE(int32_t(y)) + 16;
5381 else
5382 1648 y = TRUNCATE_TILE(int32_t(y));
5383
5384 1973 break;
5385
5386 case left:
5387 case right:
5388
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2902 times.
2906 if(x < 0)
5389 4 x = 0;
5390
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2069 times.
2902 else if((int32_t(x)&15) > 7)
5391 833 x = TRUNCATE_TILE(int32_t(x)) + 16;
5392 else
5393 2069 x = TRUNCATE_TILE(int32_t(x));
5394
5395 2906 break;
5396 }
5397
5398 4883 sclk=0;
5399 4883 clk3=0;
5400 4883 break;
5401 }
5402 }
5403
5404
2/2
✓ Branch 0 taken 83889 times.
✓ Branch 1 taken 7363 times.
91252 if((sclk&255)==0)
5405 {
5406 //hitdir = -1;
5407 7363 sclk=0;
5408 7363 }
5409 91252 return 2;
5410 15644617 }
5411
5412 bool enemy::can_slide()
5413 {
5414 if(sclk==0 || (hp<=0 && !immortal))
5415 return false;
5416
5417 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5418 {
5419 return false;
5420 }
5421
5422 return true;
5423 }
5424
5425 bool enemy::fslide()
5426 {
5427 if(sclk==0 || (hp<=0 && !immortal))
5428 return false;
5429
5430 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5431 {
5432 sclk=0;
5433 return false;
5434 }
5435
5436 --sclk;
5437
5438 switch(sclk>>8)
5439 {
5440 case up:
5441 if(y<=16)
5442 {
5443 sclk=0;
5444 return false;
5445 }
5446
5447 break;
5448
5449 case down:
5450 if(y>=world_h-16)
5451 {
5452 sclk=0;
5453 return false;
5454 }
5455
5456 break;
5457
5458 case left:
5459 if(x<=16)
5460 {
5461 sclk=0;
5462 return false;
5463 }
5464
5465 break;
5466
5467 case right:
5468 if(x>=world_w-16)
5469 {
5470 sclk=0;
5471 return false;
5472 }
5473
5474 break;
5475 }
5476 hitdir = (sclk>>8);
5477 switch(sclk>>8)
5478 {
5479 case up:
5480 y-=4;
5481 break;
5482
5483 case down:
5484 y+=4;
5485 break;
5486
5487 case left:
5488 x-=4;
5489 break;
5490
5491 case right:
5492 x+=4;
5493 break;
5494 }
5495
5496 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5497 {
5498 switch(sclk>>8)
5499 {
5500 case up:
5501 case down:
5502 if((int32_t(y)&15) > 7)
5503 y = TRUNCATE_TILE(int32_t(y)) + 16;
5504 else
5505 y = TRUNCATE_TILE(int32_t(y));
5506
5507 break;
5508
5509 case left:
5510 case right:
5511 if((int32_t(x)&15) > 7)
5512 x = TRUNCATE_TILE(int32_t(x)) + 16;
5513 else
5514 x = TRUNCATE_TILE(int32_t(x));
5515
5516 break;
5517 }
5518
5519 sclk=0;
5520 clk3=0;
5521 }
5522
5523 if((sclk&255)==0)
5524 sclk=0;
5525
5526 return true;
5527 }
5528
5529 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5530 {
5531 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5532 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5533 bool ret = sprite::knockback(time, dir, speed);
5534 if(ret) sclk = 0; //kill engine knockback if interrupted
5535 //! Perhaps also set hitdir here, if needed for timing? -Z
5536 return ret;
5537 }
5538
5539 38007122 bool enemy::runKnockback()
5540 {
5541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38007122 times.
38007122 if((script_knockback_clk&0xFF)==0)
5542 {
5543 38007122 script_knockback_clk = 0;
5544 38007122 return false;
5545 }
5546 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5547 {
5548 return false;
5549 }
5550 int32_t move = script_knockback_speed;
5551 int32_t kb_dir = script_knockback_clk>>8;
5552 --script_knockback_clk;
5553
5554 while(move>0)
5555 {
5556 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5557 move -= thismove;
5558 hitdir = kb_dir;
5559 switch(kb_dir)
5560 {
5561 case r_up:
5562 case l_up:
5563 case up:
5564 y-=thismove;
5565 break;
5566
5567 case r_down:
5568 case l_down:
5569 case down:
5570 y+=thismove;
5571 break;
5572 }
5573 switch(kb_dir)
5574 {
5575 case l_up:
5576 case l_down:
5577 case left:
5578 x-=thismove;
5579 break;
5580
5581 case r_up:
5582 case r_down:
5583 case right:
5584 x+=thismove;
5585 break;
5586 }
5587 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5588 {
5589 if(!canmove(kb_dir,(zfix)0,0,true))
5590 {
5591 script_knockback_clk=0;
5592 clk3=0;
5593 //Fix to grid
5594 switch(kb_dir)
5595 {
5596 case up:
5597 case down:
5598 break;
5599 default:
5600 if(x < 0)
5601 x = 0;
5602 else if((int32_t(x)&15) > 7)
5603 x = TRUNCATE_TILE(int32_t(x)) + 16;
5604 else
5605 x = TRUNCATE_TILE(int32_t(x));
5606 break;
5607 }
5608 switch(kb_dir)
5609 {
5610 case left:
5611 case right:
5612 break;
5613 default:
5614 if(y < 0)
5615 y = 0;
5616 else if((int32_t(y)&15) > 7)
5617 y = TRUNCATE_TILE(int32_t(y)) + 16;
5618 else
5619 y = TRUNCATE_TILE(int32_t(y));
5620 break;
5621 }
5622 break;
5623 }
5624 }
5625 else
5626 {
5627 if(!scr_canplace(x,y,0,true))
5628 {
5629 script_knockback_clk=0;
5630 clk3=0;
5631 //Fix to grid
5632 if (OFFGRID_ENEMY)
5633 {
5634 switch(kb_dir)
5635 {
5636 case up:
5637 case down:
5638 break;
5639 default:
5640 if(x < 0)
5641 x = 0;
5642 else if((int32_t(x)&7) > 3)
5643 x = TRUNCATE_HALF_TILE(int32_t(x)) + 8;
5644 else
5645 x = TRUNCATE_HALF_TILE(int32_t(x));
5646 break;
5647 }
5648 switch(kb_dir)
5649 {
5650 case left:
5651 case right:
5652 break;
5653 default:
5654 if(y < 0)
5655 y = 0;
5656 else if((int32_t(y)&7) > 3)
5657 y = TRUNCATE_HALF_TILE(int32_t(y)) + 8;
5658 else
5659 y = TRUNCATE_HALF_TILE(int32_t(y));
5660 break;
5661 }
5662 }
5663 else
5664 {
5665 switch(kb_dir)
5666 {
5667 case up:
5668 case down:
5669 break;
5670 default:
5671 if(x < 0)
5672 x = 0;
5673 else if((int32_t(x)&15) > 7)
5674 x = TRUNCATE_TILE(int32_t(x)) + 16;
5675 else
5676 x = TRUNCATE_TILE(int32_t(x));
5677 break;
5678 }
5679 switch(kb_dir)
5680 {
5681 case left:
5682 case right:
5683 break;
5684 default:
5685 if(y < 0)
5686 y = 0;
5687 else if((int32_t(y)&15) > 7)
5688 y = TRUNCATE_TILE(int32_t(y)) + 16;
5689 else
5690 y = TRUNCATE_TILE(int32_t(y));
5691 break;
5692 }
5693 }
5694 break;
5695 }
5696
5697 }
5698 }
5699 return true;
5700 38007122 }
5701 // changes enemy's direction, checking restrictions
5702 // rate: 0 = no random changes, 16 = always random change
5703 // homing: 0 = none, 256 = always
5704 // grumble 0 = none, 4 = strongest appetite
5705 520993 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5706 {
5707 520993 int32_t ndir=-1;
5708
5709
4/4
✓ Branch 0 taken 110050 times.
✓ Branch 1 taken 410943 times.
✓ Branch 2 taken 37872 times.
✓ Branch 3 taken 72178 times.
520993 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble))
5710 {
5711 72178 int32_t i = Lwpns.idFirst(wBait);
5712
1/2
✓ Branch 0 taken 72178 times.
✗ Branch 1 not taken.
72178 if(i >= 0) //idfirst returns -1 if it can't find any
5713 {
5714 weapon *w = (weapon*)Lwpns.spr(i);
5715 if (get_qr(qr_FIND_CLOSEST_BAIT))
5716 {
5717 int32_t currentrange;
5718 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5719 else currentrange = -1;
5720 int curid = i;
5721 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5722 for(; i<Lwpns.Count(); ++i)
5723 {
5724 weapon *lw = (weapon*)Lwpns.spr(i);
5725 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5726 {
5727 currentrange = distance(x, y, lw->x, lw->y);
5728 curid = i;
5729 }
5730 }
5731 i = curid;
5732 if (currentrange == -1) i = -1;
5733 }
5734 else
5735 {
5736 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5737 }
5738 if (i >= 0)
5739 {
5740 int32_t bx = Lwpns.spr(i)->x;
5741 int32_t by = Lwpns.spr(i)->y;
5742
5743 if(abs(int32_t(y)-by)>14)
5744 {
5745 ndir = (by<y) ? up : down;
5746 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5747 if(canmove(ndir,special,false))
5748 {
5749 dir=ndir;
5750 return;
5751 }
5752 }
5753
5754 ndir = (bx<x) ? left : right;
5755 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5756 if(canmove(ndir,special,false))
5757 {
5758 dir=ndir;
5759 return;
5760 }
5761 }
5762 }
5763 72178 }
5764
5765
2/2
✓ Branch 0 taken 352899 times.
✓ Branch 1 taken 168094 times.
520993 if((zc_oldrand()&255)<abs(newhoming))
5766 {
5767 168094 ndir = lined_up(8,false);
5768
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 168094 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
168094 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5769
4/4
✓ Branch 0 taken 45375 times.
✓ Branch 1 taken 122719 times.
✓ Branch 2 taken 5719 times.
✓ Branch 3 taken 39656 times.
168094 if(ndir>=0 && canmove(ndir,special,false))
5770 {
5771 39656 dir=ndir;
5772 39656 return;
5773 }
5774 128438 }
5775
5776 481337 int32_t i=0;
5777
5778
2/2
✓ Branch 0 taken 3339 times.
✓ Branch 1 taken 1180991 times.
1184330 for(; i<32; i++)
5779 {
5780 1180991 int32_t r=zc_oldrand();
5781
5782
2/2
✓ Branch 0 taken 345083 times.
✓ Branch 1 taken 835908 times.
1180991 if((r&15)<newrate)
5783 345083 ndir=(r>>4)&3;
5784 else
5785 835908 ndir=dir;
5786
5787
2/2
✓ Branch 0 taken 702993 times.
✓ Branch 1 taken 477998 times.
1180991 if(canmove(ndir,special,false))
5788 477998 break;
5789 702993 }
5790
5791
2/2
✓ Branch 0 taken 477998 times.
✓ Branch 1 taken 3339 times.
482094 if(i==32)
5792 {
5793
2/2
✓ Branch 0 taken 8935 times.
✓ Branch 1 taken 757 times.
9692 for(ndir=0; ndir<4; ndir++)
5794 {
5795
2/2
✓ Branch 0 taken 6353 times.
✓ Branch 1 taken 2582 times.
8935 if(canmove(ndir,special,false))
5796 2582 goto ok;
5797 6353 }
5798
5799
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 697 times.
757 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5800 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5801 757 }
5802
5803 ok:
5804 481337 dir = ndir;
5805 520993 }
5806
5807 2682 void enemy::newdir()
5808 {
5809 2682 newdir(4,0,spw_none);
5810 2682 }
5811
5812 zfix enemy::distance_left()
5813 {
5814 int32_t a2=x.getInt();
5815 int32_t b2=y.getInt();
5816
5817 switch(dir)
5818 {
5819 case up:
5820 return (zfix)(b2&0xF);
5821
5822 case down:
5823 return (zfix)(16-(b2&0xF));
5824
5825 case left:
5826 return (zfix)(a2&0xF);
5827
5828 case right:
5829 return (zfix)(16-(a2&0xF));
5830 }
5831
5832 return (zfix)0;
5833 }
5834
5835 // keeps walking around
5836 390294 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5837 {
5838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390294 times.
390294 if(slide())
5839 return;
5840
5841
8/12
✓ Branch 0 taken 386460 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 386460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 382033 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 382033 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 382033 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 382033 times.
390294 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5842 8261 return;
5843
5844
2/2
✓ Branch 0 taken 26043 times.
✓ Branch 1 taken 355990 times.
382033 if(clk3<=0)
5845 {
5846 26043 fix_coords(true);
5847 26043 newdir(newrate,newhoming,special);
5848
5849
1/2
✓ Branch 0 taken 26043 times.
✗ Branch 1 not taken.
26043 if(step==0)
5850 clk3=0;
5851 else
5852 26043 clk3=int32_t(16.0/step);
5853 26043 }
5854
2/2
✓ Branch 0 taken 355945 times.
✓ Branch 1 taken 45 times.
355990 else if(scored)
5855 {
5856 45 dir^=1;
5857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5858 else clk3=32767;
5859 45 }
5860
5861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 382033 times.
382033 if (step != 0) --clk3;
5862 382033 move(step);
5863 390294 }
5864
5865 void enemy::constant_walk()
5866 {
5867 constant_walk(4,0,spw_none);
5868 }
5869
5870 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5871 {
5872 35220 return (newy<<8)+newx;
5873 }
5874
5875 // for variable step rates
5876 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5877 {
5878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5879 return;
5880
5881
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5882 55444 return;
5883
5884 418370 zfix dx = (zfix)0;
5885 418370 zfix dy = (zfix)0;
5886
5887
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5888 {
5889 case 8:
5890 case up:
5891 93441 dy-=step;
5892 93441 break;
5893
5894 case 12:
5895 case down:
5896 97752 dy+=step;
5897 97752 break;
5898
5899 case 14:
5900 case left:
5901 111603 dx-=step;
5902 111603 break;
5903
5904 case 10:
5905 case right:
5906 113743 dx+=step;
5907 113743 break;
5908
5909 case 15:
5910 case l_up:
5911 dx-=step;
5912 dy-=step;
5913 break;
5914
5915 case 9:
5916 case r_up:
5917 dx+=step;
5918 dy-=step;
5919 break;
5920
5921 case 13:
5922 case l_down:
5923 dx-=step;
5924 dy+=step;
5925 break;
5926
5927 case 11:
5928 case r_down:
5929 dx+=step;
5930 dy+=step;
5931 break;
5932 }
5933
5934
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5935 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5936 {
5937 12443 fix_coords();
5938 12443 newdir(newrate,newhoming,special);
5939 12443 clk3=pos(x,y);
5940 12443 }
5941
5942 418370 move(step);
5943 473814 }
5944
5945 // pauses for a while after it makes a complete move (to a new square)
5946 12333842 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5947 {
5948
4/4
✓ Branch 0 taken 79892 times.
✓ Branch 1 taken 12253950 times.
✓ Branch 2 taken 67060 times.
✓ Branch 3 taken 12832 times.
12333842 if(sclk && clk2)
5949 {
5950 12832 clk3=0;
5951 12832 }
5952
5953
11/14
✓ Branch 0 taken 12260818 times.
✓ Branch 1 taken 73024 times.
✓ Branch 2 taken 12260818 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12260818 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11793650 times.
✓ Branch 7 taken 467168 times.
✓ Branch 8 taken 11655901 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11651365 times.
✓ Branch 11 taken 4536 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11651365 times.
12333842 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5954 {
5955 682477 return;
5956 }
5957
5958
2/2
✓ Branch 0 taken 2132811 times.
✓ Branch 1 taken 9518554 times.
11651365 if(clk2>0)
5959 {
5960 2132811 --clk2;
5961 2132811 return;
5962 }
5963
5964
2/2
✓ Branch 0 taken 411234 times.
✓ Branch 1 taken 9107320 times.
9518554 if(clk3<=0)
5965 {
5966 411234 fix_coords(true);
5967 411234 newdir(newrate,newhoming,special);
5968 411234 clk3=int32_t(16.0/step);
5969
2/2
✓ Branch 0 taken 411037 times.
✓ Branch 1 taken 197 times.
411234 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411234 times.
411234 if(clk2<0)
5971 {
5972 clk2=0;
5973 }
5974
2/2
✓ Branch 0 taken 54768 times.
✓ Branch 1 taken 356466 times.
411234 else if((zc_oldrand()&15)<newhrate)
5975 {
5976 54768 clk2=haltcnt;
5977 54768 return;
5978 }
5979 356466 }
5980
2/2
✓ Branch 0 taken 9104160 times.
✓ Branch 1 taken 3160 times.
9107320 else if(scored)
5981 {
5982 3160 dir^=1;
5983
5984
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3155 times.
3160 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5985 5 else clk3=32767;
5986 3160 }
5987
5988
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9386847 times.
9463786 if (step != 0) --clk3;
5989 9463786 move(step);
5990 12333842 }
5991
5992 // 8-directional movement, aligns to 8 pixels
5993 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5994 {
5995 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5996 return;
5997
5998 if(clk3<=0)
5999 {
6000 newdir_8(newrate,newhoming,special);
6001 clk3=int32_t(8.0/step);
6002 if (step == 0) clk3 = 32767;
6003 }
6004
6005 if (step != 0) --clk3;
6006 move(step);
6007 }
6008 // 8-directional movement, aligns to 8 pixels
6009 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6010 {
6011
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6012 return;
6013
6014
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6015 {
6016 16235 newdir_8(newrate,newhoming,special);
6017 16235 clk3=int32_t(8.0/step);
6018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6019 16235 }
6020
6021
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6022 242393 move(step);
6023 242393 }
6024
6025 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6026 {
6027 if(clk<0 || dying || stunclk || watch || frozenclock)
6028 return;
6029
6030 if(!canmove(dir,step,special,false))
6031 clk3=0;
6032
6033 if(clk2>0)
6034 {
6035 --clk2;
6036 return;
6037 }
6038
6039 if(clk3<=0)
6040 {
6041 newdir_8(newrate,newhoming,special);
6042 clk3=newclk;
6043
6044 if(clk2<0)
6045 {
6046 clk2=0;
6047 }
6048 else if((zc_oldrand()&15)<newhrate)
6049 {
6050 newdir_8(newrate,newhoming,special);
6051 clk2=haltcnt;
6052 return;
6053 }
6054 }
6055
6056 --clk3;
6057 move(step);
6058 }
6059
6060 // 8-directional movement, no alignment
6061 4721025 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6062 {
6063
9/12
✓ Branch 0 taken 4511755 times.
✓ Branch 1 taken 209270 times.
✓ Branch 2 taken 4511755 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4485134 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4474087 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4474087 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4474087 times.
4721025 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6064 246938 return;
6065
6066
2/2
✓ Branch 0 taken 4443599 times.
✓ Branch 1 taken 30488 times.
4474087 if(!canmove(dir,step,special,false))
6067 30488 clk3=0;
6068
6069
2/2
✓ Branch 0 taken 3916070 times.
✓ Branch 1 taken 558017 times.
4474087 if(clk3<=0)
6070 {
6071 558017 newdir_8(newrate,newhoming,special);
6072 558017 clk3=newclk;
6073 558017 }
6074
6075 4474087 --clk3;
6076 4474087 move(step);
6077 4721025 }
6078
6079 // same as above but with variable enemy size
6080 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6081 {
6082
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6083 1247 return;
6084
6085
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6086 1334 clk3=0;
6087
6088
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6089 {
6090 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6091 6475 clk3=newclk;
6092 6475 }
6093
6094 93316 --clk3;
6095 93316 move(step);
6096 94563 }
6097
6098 // the variable speed floater movement
6099 // ms is max speed
6100 // ss is step speed
6101 // s is step count
6102 // p is pause count
6103 // g is graduality :)
6104 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6105 4019514 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6106 {
6107 4019514 ++clk2;
6108 4019514 byte over_pit = overpit(this);
6109
6110
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2904720 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
4019514 if(dmisc1 && over_pit) p = 0;
6111
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56650 times.
✓ Branch 2 taken 1586380 times.
✓ Branch 3 taken 2243416 times.
✓ Branch 4 taken 133068 times.
4019514 switch(movestatus)
6112 {
6113 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6114 //! if the conditions prevent it, we jump back to case 2.
6115 case 0: // paused
6116
2/2
✓ Branch 0 taken 55199 times.
✓ Branch 1 taken 1451 times.
56650 if(clk2>=p)
6117 {
6118 1451 movestatus=1;
6119 1451 clk2=0;
6120 1451 }
6121
6122 56650 break;
6123
6124 case 1: // speeding up
6125
1/2
✓ Branch 0 taken 1586380 times.
✗ Branch 1 not taken.
1586380 if (s >= 0)
6126 {
6127
2/2
✓ Branch 0 taken 1575074 times.
✓ Branch 1 taken 11306 times.
1586380 if(clk2<g*s)
6128 {
6129
2/2
✓ Branch 0 taken 1473474 times.
✓ Branch 1 taken 101600 times.
1575074 if(!((clk2-1)%g))
6130 101600 step+=ss;
6131 1575074 }
6132 else
6133 {
6134 11306 movestatus=2;
6135 11306 clk2=0;
6136 }
6137 1586380 }
6138 else
6139 {
6140 if(step < ms)
6141 {
6142 if(!((clk2-1)%g))
6143 {
6144 step+=ss;
6145 if (step >= ms) step = ms;
6146 }
6147 }
6148 else
6149 {
6150 step = ms;
6151 movestatus=2;
6152 clk2=0;
6153 }
6154 }
6155
6156 1586380 break;
6157
6158 case 2: // normal
6159 2243416 step=ms;
6160
6161
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2243416 times.
✓ Branch 2 taken 481019 times.
✓ Branch 3 taken 1762397 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1762397 times.
✓ Branch 6 taken 1760147 times.
✓ Branch 7 taken 2250 times.
2243416 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6162 {
6163
1/2
✓ Branch 0 taken 2250 times.
✗ Branch 1 not taken.
2250 if (s >= 0) step=ss*s;
6164 else step=ms;
6165 2250 movestatus=3;
6166 2250 clk2=0;
6167 2250 }
6168
6169 2243416 break;
6170
6171 case 3: // slowing down
6172
1/2
✓ Branch 0 taken 133068 times.
✗ Branch 1 not taken.
133068 if (s >= 0)
6173 {
6174
2/2
✓ Branch 0 taken 131387 times.
✓ Branch 1 taken 1681 times.
133068 if(clk2<=g*s)
6175 {
6176 { //don't slow down over pits
6177
6178
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 131120 times.
131387 if(over_pit)
6179 {
6180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6181 {
6182 step=ms;
6183 }
6184 267 }
6185 else //can slow down
6186 {
6187
4/4
✓ Branch 0 taken 8088 times.
✓ Branch 1 taken 123032 times.
✓ Branch 2 taken 7720 times.
✓ Branch 3 taken 368 times.
131120 if(!(clk2%g) && !dmisc1)
6188 7720 step-=ss;
6189 }
6190 }
6191
6192
6193 131387 }
6194 else
6195 {
6196 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6197 //this doesn't help keese, as they have a z of 0.
6198 //they always nee to run this check.
6199 {
6200
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1681 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1681 if(over_pit &&!dmisc1)
6201 {
6202 --clk2; //if over a pit, don't land, and revert clock change
6203 }
6204 else //can land safely
6205 {
6206 1681 movestatus=0;
6207
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 566 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1681 if(dmisc1&&!over_pit)
6208 1115 step=0;
6209 1681 clk2=0;
6210 }
6211 }
6212
6213 }
6214 133068 }
6215 else
6216 {
6217 if(step > 0)
6218 {
6219 if(over_pit)
6220 {
6221 if(dmisc1)
6222 {
6223 step=ms;
6224 }
6225 }
6226 else //can slow down
6227 {
6228 if(!(clk2%g))
6229 step-=ss;
6230 }
6231 }
6232 else
6233 {
6234 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6235 //this doesn't help keese, as they have a z of 0.
6236 //they always nee to run this check.
6237 if(over_pit)
6238 {
6239 step+=ss; //if over a pit, don't land, and revert clock change
6240 }
6241 else //can land safely
6242 {
6243 movestatus=0;
6244 step=0;
6245 clk2=0;
6246 }
6247 }
6248 }
6249
6250 133068 break;
6251 }
6252
6253
2/2
✓ Branch 0 taken 2252472 times.
✓ Branch 1 taken 1767042 times.
4019514 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6254 4019514 }
6255
6256 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6257 {
6258 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6259 }
6260
6261 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6262 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6263 927919 int32_t enemy::lined_up(int32_t range, bool dir8)
6264 {
6265 927919 int32_t lx = Hero.getX();
6266 927919 int32_t ly = Hero.getY();
6267
6268
2/2
✓ Branch 0 taken 38904 times.
✓ Branch 1 taken 889015 times.
927919 if(abs(lx-int32_t(x))<=range)
6269 {
6270
2/2
✓ Branch 0 taken 16349 times.
✓ Branch 1 taken 22555 times.
38904 if(ly<y)
6271 {
6272 16349 return up;
6273 }
6274
6275 22555 return down;
6276 }
6277
6278
2/2
✓ Branch 0 taken 56356 times.
✓ Branch 1 taken 832659 times.
889015 if(abs(ly-int32_t(y))<=range)
6279 {
6280
2/2
✓ Branch 0 taken 30298 times.
✓ Branch 1 taken 26058 times.
56356 if(lx<x)
6281 {
6282 30298 return left;
6283 }
6284
6285 26058 return right;
6286 }
6287
6288
2/2
✓ Branch 0 taken 160069 times.
✓ Branch 1 taken 672590 times.
832659 if(dir8)
6289 {
6290
2/2
✓ Branch 0 taken 253848 times.
✓ Branch 1 taken 418742 times.
672590 if(abs(lx-x)-abs(ly-y)<=range)
6291 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6292 {
6293
2/2
✓ Branch 0 taken 106080 times.
✓ Branch 1 taken 147768 times.
253848 if(ly<y)
6294 {
6295
2/2
✓ Branch 0 taken 56676 times.
✓ Branch 1 taken 49404 times.
106080 if(lx<x)
6296 {
6297 56676 return l_up;
6298 }
6299 else
6300 {
6301 49404 return r_up;
6302 }
6303 }
6304 else
6305 {
6306
2/2
✓ Branch 0 taken 76696 times.
✓ Branch 1 taken 71072 times.
147768 if(lx<x)
6307 {
6308 71072 return l_down;
6309 }
6310 else
6311 {
6312 76696 return r_down;
6313 }
6314 }
6315 }
6316 418742 }
6317
6318 578811 return -1;
6319 927919 }
6320
6321 // returns true if Hero is within 'range' pixels of the enemy
6322 27884 bool enemy::HeroInRange(int32_t range)
6323 {
6324 27884 int32_t lx = Hero.getX();
6325 27884 int32_t ly = Hero.getY();
6326
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6327 }
6328
6329 // place the enemy in line with Hero (red wizzrobes)
6330 4899 void enemy::place_on_axis(bool floater, bool solid_ok)
6331 {
6332
6/6
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 4312 times.
✓ Branch 2 taken 4355 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 3768 times.
4899 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6333
6/6
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 4460 times.
✓ Branch 2 taken 4109 times.
✓ Branch 3 taken 790 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 3670 times.
4899 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6334 4899 int32_t pos2=zc_oldrand()%23;
6335 4899 int32_t tried=0;
6336 4899 bool last_resort,placed=false;
6337
6338
6339 4899 do
6340 {
6341
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 3127 times.
7587 if(pos2<14)
6342 {
6343 4460 x=(pos2<<4)+16;
6344 4460 y=ly;
6345 4460 }
6346 else
6347 {
6348 3127 x=lx;
6349 3127 y=((pos2-14)<<4)+16;
6350 }
6351
6352 // Don't commit to a last resort if position is out of bounds.
6353
6/6
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 339 times.
✓ Branch 2 taken 6936 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 6679 times.
7587 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6354
6355
4/4
✓ Branch 0 taken 3907 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 4862 times.
✓ Branch 3 taken 1339 times.
7587 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6356 {
6357 // Red Wizzrobes should be able to appear on water, but not other
6358 // solid combos; however, they could appear on solid combos in 2.10,
6359 // and some quests depend on that.
6360
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6201 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 4899 times.
8542 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6361 8542 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6362 4899 placed=true;
6363 8542 }
6364
6365
3/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4589 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2688 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7277 if(!placed && tried>=22 && last_resort)
6366 {
6367 placed=true;
6368 }
6369
6370 7277 ++tried;
6371 7277 pos2=(pos2+3)%23;
6372
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4589 times.
7277 }
6373 7277 while(!placed);
6374
6375
2/2
✓ Branch 0 taken 2781 times.
✓ Branch 1 taken 1808 times.
4589 if(y==ly)
6376 2781 dir=(x<lx)?right:left;
6377 else
6378 1808 dir=(y<ly)?down:up;
6379
6380 4589 clk2=tried;
6381 4589 }
6382
6383 20334859 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6384 {
6385 20334859 int32_t t = o_tile;
6386 20334859 int32_t b = o_tile;
6387
6388 // Darknuts, but also Wizzrobes and Wallmasters
6389
3/4
✓ Branch 0 taken 8417552 times.
✓ Branch 1 taken 10877537 times.
✓ Branch 2 taken 1039770 times.
✗ Branch 3 not taken.
20334859 switch(family)
6390 {
6391 case eeWALK:
6392
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10372130 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10877537 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6393 {
6394 367468 tile=s_tile;
6395 367468 t=s_tile;
6396 367468 b=s_tile;
6397 367468 }
6398
6399 10877537 break;
6400
6401 case eeTRAP:
6402
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 846204 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1039770 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6403 {
6404 193566 tile=s_tile;
6405 193566 t=s_tile;
6406 193566 b=s_tile;
6407 193566 }
6408
6409 1039770 break;
6410
6411 case eeSPINTILE:
6412 if(misc>=96 && do_animation)
6413 {
6414 tile=o_tile+frames*ndir;
6415 t=tile;
6416 }
6417
6418 break;
6419 }
6420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20334859 times.
20334859 if ( do_animation )
6421 {
6422
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20137817 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19870686 times.
20334859 if(ndir!=0) switch(frames)
6423 {
6424 case 2:
6425 267131 tiledir_small(dir,ndir==4);
6426 267131 break;
6427
6428 case 3:
6429 tiledir_three(dir);
6430 break;
6431
6432 case 4:
6433 19870686 tiledir(dir,ndir==4);
6434 19870686 break;
6435 20137817 }
6436
6437
2/2
✓ Branch 0 taken 10877537 times.
✓ Branch 1 taken 9457322 times.
20334859 if(family==eeWALK)
6438
6/6
✓ Branch 0 taken 10816528 times.
✓ Branch 1 taken 61009 times.
✓ Branch 2 taken 8211367 times.
✓ Branch 3 taken 2666170 times.
✓ Branch 4 taken 2650447 times.
✓ Branch 5 taken 15723 times.
10877537 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6439 else
6440 9457322 tile+=f4;
6441 20334859 }
6442 20334859 return b;
6443 }
6444
6445 void enemy::tiledir_three(int32_t ndir)
6446 {
6447 if ( !do_animation ) return;
6448 flip=0;
6449
6450 switch(ndir)
6451 {
6452 case right:
6453 tile+=3;
6454 [[fallthrough]];
6455
6456 case left:
6457 tile+=3;
6458 [[fallthrough]];
6459
6460 case down:
6461 tile+=3;
6462 [[fallthrough]];
6463
6464 case up:
6465 break;
6466 }
6467 }
6468
6469 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6470 {
6471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6472 267131 flip=0;
6473
6474
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6475 {
6476 case 8:
6477 case up:
6478 53829 break;
6479
6480 case 12:
6481 case down:
6482 54679 tile+=2;
6483 54679 break;
6484
6485 case 14:
6486 case left:
6487 67727 tile+=4;
6488 67727 break;
6489
6490 case 10:
6491 case right:
6492 71182 tile+=6;
6493 71182 break;
6494
6495 case 9:
6496 case r_up:
6497
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6498 5706 break;
6499
6500 tile+=10;
6501 break;
6502
6503 case 11:
6504 case r_down:
6505
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6506 5154 tile+=2;
6507 else
6508 tile+=14;
6509
6510 5154 break;
6511
6512 case 13:
6513 case l_down:
6514
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6515 4872 tile+=2;
6516 else
6517 tile+=12;
6518
6519 4872 break;
6520
6521 case 15:
6522 case l_up:
6523
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6524 3982 break;
6525
6526 tile+=8;
6527 break;
6528
6529 default:
6530 //dir=(zc_oldrand()*100)%8;
6531 //tiledir_small(dir);
6532 // flip=zc_oldrand()&3;
6533 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6534 break;
6535 }
6536 267131 }
6537
6538 23203434 void enemy::tiledir(int32_t ndir, bool fourdir)
6539 {
6540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23203434 times.
23203434 if ( !do_animation ) return;
6541 23203434 flip=0;
6542
6543
9/9
✓ Branch 0 taken 4509460 times.
✓ Branch 1 taken 4163411 times.
✓ Branch 2 taken 5444983 times.
✓ Branch 3 taken 5198041 times.
✓ Branch 4 taken 834140 times.
✓ Branch 5 taken 1027612 times.
✓ Branch 6 taken 1106457 times.
✓ Branch 7 taken 852481 times.
✓ Branch 8 taken 66849 times.
23203434 switch(ndir)
6544 {
6545 case 8:
6546 case up:
6547 4509460 break;
6548
6549 case 12:
6550 case down:
6551 4163411 tile+=4;
6552 4163411 break;
6553
6554 case 14:
6555 case left:
6556 5444983 tile+=8;
6557 5444983 break;
6558
6559 case 10:
6560 case right:
6561 5198041 tile+=12;
6562 5198041 break;
6563
6564 case 9:
6565 case r_up:
6566
2/2
✓ Branch 0 taken 89257 times.
✓ Branch 1 taken 744883 times.
834140 if(fourdir)
6567 89257 break;
6568 else
6569 744883 tile+=24;
6570
6571 744883 break;
6572
6573 case 11:
6574 case r_down:
6575
2/2
✓ Branch 0 taken 102657 times.
✓ Branch 1 taken 924955 times.
1027612 if(fourdir)
6576 102657 tile+=4;
6577 else
6578 924955 tile+=32;
6579
6580 1027612 break;
6581
6582 case 13:
6583 case l_down:
6584
2/2
✓ Branch 0 taken 106171 times.
✓ Branch 1 taken 1000286 times.
1106457 if(fourdir)
6585 106171 tile+=4;
6586 else
6587 1000286 tile+=28;
6588
6589 1106457 break;
6590
6591 case 15:
6592 case l_up:
6593
2/2
✓ Branch 0 taken 82882 times.
✓ Branch 1 taken 769599 times.
852481 if(fourdir)
6594 82882 break;
6595 else
6596 769599 tile+=20;
6597
6598 769599 break;
6599
6600 default:
6601 //dir=(zc_oldrand()*100)%8;
6602 //tiledir(dir);
6603 // flip=zc_oldrand()&3;
6604 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6605 66849 break;
6606 }
6607 23203434 }
6608
6609 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6610 {
6611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6612 3868 flip=0;
6613
6614
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6615 {
6616 case 8:
6617 case up:
6618 297 break;
6619
6620 case 12:
6621 case down:
6622 tile+=8;
6623 break;
6624
6625 case 14:
6626 case left:
6627 195 tile+=40;
6628 195 break;
6629
6630 case 10:
6631 case right:
6632 179 tile+=48;
6633 179 break;
6634
6635 case 9:
6636 case r_up:
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6638 break;
6639
6640 306 tile+=88;
6641 306 break;
6642
6643 case 11:
6644 case r_down:
6645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6646 tile+=8;
6647 else
6648 1235 tile+=128;
6649
6650 1235 break;
6651
6652 case 13:
6653 case l_down:
6654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6655 tile+=8;
6656 else
6657 1324 tile+=120;
6658
6659 1324 break;
6660
6661 case 15:
6662 case l_up:
6663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6664 break;
6665
6666 332 tile+=80;
6667 332 break;
6668
6669 default:
6670 //dir=(zc_oldrand()*100)%8;
6671 //tiledir_big(dir);
6672 // flip=zc_oldrand()&3;
6673 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6674 break;
6675 }
6676 3868 }
6677
6678 40162270 void enemy::update_enemy_frame()
6679 {
6680
4/4
✓ Branch 0 taken 40159895 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40159888 times.
40162270 if(fallclk||drownclk) return;
6681
1/2
✓ Branch 0 taken 40159888 times.
✗ Branch 1 not taken.
40159888 if (!do_animation)
6682 return;
6683
6684
4/4
✓ Branch 0 taken 1549143 times.
✓ Branch 1 taken 38610745 times.
✓ Branch 2 taken 1547136 times.
✓ Branch 3 taken 2007 times.
40159888 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6685
6686
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
40159888 if(get_qr(qr_ANONE_NOANIM)
6687
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40159888 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40159888 && anim == aNONE && family != eeGUY)
6688 return;
6689
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39788512 times.
40159888 int32_t newfrate = zc_max(frate,4);
6690 40159888 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6691 40159888 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6692
2/2
✓ Branch 0 taken 30163670 times.
✓ Branch 1 taken 9996218 times.
40159888 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6693 40159888 tile = o_tile;
6694 40159888 int32_t basetile = o_tile;
6695 40159888 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6696 40159888 bool ignore_extend = false;
6697
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 209083 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5096784 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1525813 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 693272 times.
✓ Branch 22 taken 1694619 times.
✓ Branch 23 taken 1134909 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4134380 times.
✓ Branch 27 taken 7515986 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582937 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 219096 times.
✓ Branch 33 taken 1818304 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 7018408 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
40159888 switch(anim)
6698 {
6699
6700 case aDONGO:
6701 {
6702 69324 int32_t fr = stunclk>0 ? 16 : 8;
6703
6704
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6705 {
6706 // bloated
6707
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6708 {
6709 case up:
6710 960 tile+=9;
6711 960 flip=0;
6712 960 xofs=0;
6713 960 dummy_int[1]=0; //no additional tiles
6714 960 break;
6715
6716 case down:
6717 960 tile+=7;
6718 960 flip=0;
6719 960 xofs=0;
6720 960 dummy_int[1]=0; //no additional tiles
6721 960 break;
6722
6723 case left:
6724 1664 flip=1;
6725 1664 tile+=4;
6726 1664 xofs=16;
6727 1664 dummy_int[1]=1; //second tile is next tile
6728 1664 break;
6729
6730 case right:
6731 896 flip=0;
6732 896 tile+=5;
6733 896 xofs=16;
6734 896 dummy_int[1]=-1; //second tile is previous tile
6735 896 break;
6736 }
6737 4480 }
6738
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6739 {
6740 // normal
6741
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6742 {
6743 case up:
6744 13652 tile+=8;
6745 13652 flip=(clk&fr)?1:0;
6746 13652 xofs=0;
6747 13652 dummy_int[1]=0; //no additional tiles
6748 13652 break;
6749
6750 case down:
6751 15374 tile+=6;
6752 15374 flip=(clk&fr)?1:0;
6753 15374 xofs=0;
6754 15374 dummy_int[1]=0; //no additional tiles
6755 15374 break;
6756
6757 case left:
6758 19615 flip=1;
6759 19615 tile+=(clk&fr)?2:0;
6760 19615 xofs=16;
6761 19615 dummy_int[1]=1; //second tile is next tile
6762 19615 break;
6763
6764 case right:
6765 15086 flip=0;
6766 15086 tile+=(clk&fr)?3:1;
6767 15086 xofs=16;
6768 15086 dummy_int[1]=-1; //second tile is next tile
6769 15086 break;
6770 }
6771 63727 }
6772 }
6773 69324 break;
6774
6775 case aNEWDONGO:
6776 {
6777 53456 int32_t fr4=0;
6778
6779
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6780 {
6781 // bloated
6782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6783 {
6784 2752 fr4=3;
6785 2752 }
6786
6787
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6788 {
6789 2107 fr4=2;
6790 2107 }
6791
6792
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6793 {
6794 1419 fr4=1;
6795 1419 }
6796
6797
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6798 {
6799 731 fr4=0;
6800 731 }
6801
6802
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6803 {
6804 case up:
6805 256 xofs=0;
6806 256 tile+=8+fr4;
6807 256 dummy_int[1]=0; //no additional tiles
6808 256 break;
6809
6810 case down:
6811 576 xofs=0;
6812 576 tile+=12+fr4;
6813 576 dummy_int[1]=0; //no additional tiles
6814 576 break;
6815
6816 case left:
6817 704 tile+=29+(2*fr4);
6818 704 xofs=16;
6819 704 dummy_int[1]=-1; //second tile is previous tile
6820 704 break;
6821
6822 case right:
6823 1216 tile+=49+(2*fr4);
6824 1216 xofs=16;
6825 1216 dummy_int[1]=-1; //second tile is previous tile
6826 1216 break;
6827 }
6828 2752 }
6829
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6830 {
6831 // normal
6832
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6833 {
6834 case up:
6835 9234 xofs=0;
6836 9234 tile+=((clk&12)>>2);
6837 9234 dummy_int[1]=0; //no additional tiles
6838 9234 break;
6839
6840 case down:
6841 9871 xofs=0;
6842 9871 tile+=4+((clk&12)>>2);
6843 9871 dummy_int[1]=0; //no additional tiles
6844 9871 break;
6845
6846 case left:
6847 15025 tile+=21+((clk&12)>>1);
6848 15025 xofs=16;
6849 15025 dummy_int[1]=-1; //second tile is previous tile
6850 15025 break;
6851
6852 case right:
6853 15676 flip=0;
6854 15676 tile+=41+((clk&12)>>1);
6855 15676 xofs=16;
6856 15676 dummy_int[1]=-1; //second tile is previous tile
6857 15676 break;
6858 }
6859 49806 }
6860 }
6861 53456 break;
6862
6863 case aDONGOBS:
6864 {
6865 38833 int32_t fr4=0;
6866
6867
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6868 {
6869 // bloated
6870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6871 {
6872 2688 fr4=3;
6873 2688 }
6874
6875
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6876 {
6877 2058 fr4=2;
6878 2058 }
6879
6880
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6881 {
6882 1386 fr4=1;
6883 1386 }
6884
6885
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6886 {
6887 714 fr4=0;
6888 714 }
6889
6890
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6891 {
6892 case up:
6893 256 tile+=28+fr4;
6894 256 yofs+=8;
6895 256 dummy_int[1]=-20; //second tile change
6896 256 dummy_int[2]=0; //new xofs change
6897 256 dummy_int[3]=-16; //new xofs change
6898 256 break;
6899
6900 case down:
6901 384 tile+=12+fr4;
6902 384 yofs-=8;
6903 384 dummy_int[1]=20; //second tile change
6904 384 dummy_int[2]=0; //new xofs change
6905 384 dummy_int[3]=16; //new xofs change
6906 384 break;
6907
6908 case left:
6909 1024 tile+=49+(2*fr4);
6910 1024 xofs+=8;
6911 1024 dummy_int[1]=-1; //second tile change
6912 1024 dummy_int[2]=-16; //new xofs change
6913 1024 dummy_int[3]=0; //new xofs change
6914 1024 break;
6915
6916 case right:
6917 1024 tile+=69+(2*fr4);
6918 1024 xofs+=8;
6919 1024 dummy_int[1]=-1; //second tile change
6920 1024 dummy_int[2]=-16; //new xofs change
6921 1024 dummy_int[3]=0; //new xofs change
6922 1024 break;
6923 }
6924 2688 }
6925
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6926 {
6927 // normal
6928
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6929 {
6930 case up:
6931 7136 tile+=20+((clk&24)>>3);
6932 7136 yofs+=8;
6933 7136 dummy_int[1]=-20; //second tile change
6934 7136 dummy_int[2]=0; //new xofs change
6935 7136 dummy_int[3]=-16; //new xofs change
6936 7136 break;
6937
6938 case down:
6939 6672 tile+=4+((clk&24)>>3);
6940 6672 yofs-=8;
6941 6672 dummy_int[1]=20; //second tile change
6942 6672 dummy_int[2]=0; //new xofs change
6943 6672 dummy_int[3]=16; //new xofs change
6944 6672 break;
6945
6946 case left:
6947 11075 xofs=-8;
6948 11075 tile+=40+((clk&24)>>2);
6949 11075 dummy_int[1]=1; //second tile change
6950 11075 dummy_int[2]=16; //new xofs change
6951 11075 dummy_int[3]=0; //new xofs change
6952 11075 break;
6953
6954 case right:
6955 10601 tile+=60+((clk&24)>>2);
6956 10601 xofs=-8;
6957 10601 dummy_int[1]=1; //second tile change
6958 10601 dummy_int[2]=16; //new xofs change
6959 10601 dummy_int[3]=0; //new xofs change
6960 10601 break;
6961 }
6962 35484 }
6963 }
6964 38833 break;
6965
6966 case aWIZZ:
6967 {
6968 // if(d->misc1)
6969
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6970 {
6971
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6972 {
6973 91127 ++tile;
6974 91127 }
6975 182184 }
6976 else
6977 {
6978
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6979 {
6980 136489 ++tile;
6981 136489 }
6982 }
6983
6984
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6985 {
6986 case 9:
6987 case 15:
6988 case up:
6989 76094 tile+=2;
6990 76094 break;
6991
6992 case down:
6993 76591 break;
6994
6995 case 13:
6996 case left:
6997 157108 flip=1;
6998 157108 break;
6999
7000 default:
7001 145581 flip=0;
7002 145581 break;
7003 }
7004 }
7005 455374 break;
7006
7007 case aNEWWIZZ:
7008 {
7009 1525813 tiledir(dir,true);
7010
7011 // if(d->misc1) //walking wizzrobe
7012
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 783389 times.
1525813 if(dmisc1) //walking wizzrobe
7013 {
7014
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7015 {
7016 369103 tile+=2;
7017 369103 }
7018
7019
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7020 {
7021 370339 tile+=1;
7022 370339 }
7023
7024
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7025 {
7026
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7027 {
7028 79162 tile+=40;
7029 79162 }
7030 742424 }
7031 742424 }
7032 else
7033 {
7034
4/4
✓ Branch 0 taken 716244 times.
✓ Branch 1 taken 67145 times.
✓ Branch 2 taken 168827 times.
✓ Branch 3 taken 547417 times.
783389 if(dummy_bool[1]||dummy_bool[2])
7035 {
7036 235972 tile+=20;
7037
7038
2/2
✓ Branch 0 taken 67136 times.
✓ Branch 1 taken 168836 times.
235972 if(dummy_bool[2])
7039 {
7040 168836 tile+=20;
7041 168836 }
7042 235972 }
7043
7044 783389 tile+=((frame>>1)&3);
7045 }
7046 }
7047 1525813 break;
7048
7049 case a3FRM:
7050 {
7051
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7052 }
7053 197042 break;
7054
7055 case a3FRM4DIR:
7056 {
7057 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7058 }
7059 break;
7060
7061 case aVIRE:
7062 {
7063
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7064 {
7065 29292 tile+=2;
7066 29292 }
7067
7068 128880 tile+=fx;
7069 }
7070 128880 break;
7071
7072 case aROPE:
7073 {
7074 220021 tile+=(1-fx);
7075 220021 flip = dir==left ? 1:0;
7076 }
7077 220021 break;
7078
7079 case aZORA:
7080 {
7081 int32_t dl;
7082
7083
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7084 {
7085 46739 dl=clk+5;
7086 46739 goto waves2;
7087 }
7088
7089
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7090
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7091 else
7092 {
7093 92458 dl=clk-36-66;
7094 waves2:
7095 139197 tile=((dl/11)&1)+s_tile;
7096 139197 basetile = s_tile;
7097 }
7098 }
7099 221637 break;
7100
7101 case aNEWZORA:
7102 {
7103 693272 f4=(clk/16)%4;
7104
7105 693272 tiledir(dir,true);
7106 int32_t dl;
7107
7108
4/4
✓ Branch 0 taken 489980 times.
✓ Branch 1 taken 203292 times.
✓ Branch 2 taken 251304 times.
✓ Branch 3 taken 238676 times.
693272 if((clk>35)&&(clk<36+67)) //surfaced
7109 {
7110
4/4
✓ Branch 0 taken 204043 times.
✓ Branch 1 taken 34633 times.
✓ Branch 2 taken 29458 times.
✓ Branch 3 taken 174585 times.
238676 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7111 {
7112 174585 tile+=80;
7113 174585 } //mouth closed
7114 else
7115 {
7116 64091 tile+=40;
7117 }
7118
7119 238676 tile+=f4;
7120 238676 }
7121 else
7122 {
7123
2/2
✓ Branch 0 taken 203292 times.
✓ Branch 1 taken 251304 times.
454596 if(clk<36)
7124 {
7125 203292 dl=clk+5;
7126 203292 }
7127 else
7128 {
7129 251304 dl=clk-36-66;
7130 }
7131
7132 454596 tile+=((dl/5)&3);
7133 }
7134 }
7135 693272 break;
7136
7137 case a4FRM4EYE:
7138 case a2FRM4EYE:
7139 case a4FRM8EYE:
7140 case a4FRM8EYEB: //big version
7141 case a4FRM4EYEB:
7142 {
7143 836734 tilerows = 2;
7144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7146 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7147 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7148 836734 int32_t lookat=zc_oldrand()&15;
7149
7150
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7151 {
7152 210774 lookat=l_down;
7153 210774 }
7154
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7155 {
7156 226850 lookat=down;
7157 226850 }
7158
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7159 {
7160 108837 lookat=r_down;
7161 108837 }
7162
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7163 {
7164 70395 lookat=right;
7165 70395 }
7166
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7167 {
7168 35067 lookat=r_up;
7169 35067 }
7170
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7171 {
7172 25436 lookat=up;
7173 25436 }
7174
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7175 {
7176 36803 lookat=l_up;
7177 36803 }
7178 else
7179 {
7180 122572 lookat=left;
7181 }
7182
7183 836734 int32_t dir2 = dir;
7184 836734 dir = lookat;
7185
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7186 else
7187 {
7188 tiledir_big(dir,(anim == a4FRM4EYEB));
7189 tile+=2*f4;
7190 ignore_extend = true;
7191 }
7192 836734 dir = dir2;
7193 }
7194 836734 break;
7195
7196 case aFLIP:
7197 {
7198 1694619 flip = f2&1;
7199 }
7200 1694619 break;
7201
7202 case a2FRM:
7203 {
7204 1134909 tile += (1-f2);
7205 }
7206 1134909 break;
7207
7208 case a2FRMB:
7209 {
7210 tile+= 2*(1-f2);
7211 ignore_extend = true;
7212 }
7213 break;
7214
7215 case a2FRM4DIR:
7216 {
7217 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7218 }
7219 267131 break;
7220
7221 case a4FRM4DIRF:
7222 {
7223 4134380 basetile = n_frame_n_dir(4,4,f4);
7224
7225
2/2
✓ Branch 0 taken 2733532 times.
✓ Branch 1 taken 1400848 times.
4134380 if(clk2>0) //stopped to fire
7226 {
7227 1400848 tile+=20;
7228
7229
2/2
✓ Branch 0 taken 698186 times.
✓ Branch 1 taken 702662 times.
1400848 if(clk2<17) //firing
7230 {
7231 702662 tile+=20;
7232 702662 }
7233 1400848 }
7234 }
7235 4134380 break;
7236
7237 case a4FRM4DIR:
7238 {
7239 7515986 basetile = n_frame_n_dir(4,4,f4);
7240 }
7241 7515986 break;
7242
7243 case a4FRM8DIRF:
7244 {
7245 tilerows = 2;
7246 basetile = n_frame_n_dir(4,8,f4);
7247
7248 if(clk2>0) //stopped to fire
7249 {
7250 tile+=40;
7251
7252 if(clk2<17) //firing
7253 {
7254 tile+=40;
7255 }
7256 }
7257 }
7258 break;
7259
7260 case a4FRM8DIRB:
7261 case a4FRM8DIRFB:
7262 {
7263 3868 tilerows = 2;
7264 3868 tiledir_big(dir,false);
7265 3868 tile+=2*f4;
7266
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7267 {
7268 tile+=80;
7269
7270 if(clk2<17) //firing
7271 {
7272 tile+=80;
7273 }
7274 }
7275 3868 ignore_extend = true;
7276 }
7277 3868 break;
7278
7279 case a4FRM4DIRB:
7280 case a4FRM4DIRFB:
7281 {
7282 tilerows = 2;
7283 tiledir_big(dir,true);
7284 tile+=2*f4;
7285 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7286 {
7287 tile+=40;
7288
7289 if(clk2<17) //firing
7290 {
7291 tile+=40;
7292 }
7293 }
7294 ignore_extend = true;
7295 }
7296 break;
7297
7298 case aOCTO:
7299 {
7300
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165651 times.
✓ Branch 4 taken 157227 times.
582937 switch(dir)
7301 {
7302 case up:
7303 122459 flip = 2;
7304 122459 break;
7305
7306 case down:
7307 133448 flip = 0;
7308 133448 break;
7309
7310 case left:
7311 165651 flip = 0;
7312 165651 tile += 2;
7313 165651 break;
7314
7315 case right:
7316 157227 flip = 1;
7317 157227 tile += 2;
7318 157227 break;
7319 }
7320
7321 582937 tile+=f2;
7322 }
7323 582937 break;
7324
7325 case aWALK:
7326 {
7327
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7328 {
7329 case up:
7330 248704 tile+=3;
7331 248704 flip = f2;
7332 248704 break;
7333
7334 case down:
7335 267165 tile+=2;
7336 267165 flip = f2;
7337 267165 break;
7338
7339 case left:
7340 331694 flip=1;
7341 331694 tile += f2;
7342 331694 break;
7343
7344 case right:
7345 325802 flip=0;
7346 325802 tile += f2;
7347 325802 break;
7348 }
7349 }
7350 1178979 break;
7351
7352 case aDWALK:
7353 {
7354
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7355 {
7356 tile=s_tile;
7357 basetile = s_tile;
7358 }
7359
7360
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7361 {
7362 case up:
7363 177728 tile+=2;
7364 177728 flip=f2;
7365 177728 break;
7366
7367 case down:
7368 185581 flip=0;
7369 185581 tile+=(1-f2);
7370 185581 break;
7371
7372 case left:
7373 260885 flip=1;
7374 260885 tile+=(3+f2);
7375 260885 break;
7376
7377 case right:
7378 255982 flip=0;
7379 255982 tile+=(3+f2);
7380 255982 break;
7381 }
7382 }
7383 880176 break;
7384
7385 case aTEK:
7386 {
7387
2/2
✓ Branch 0 taken 139976 times.
✓ Branch 1 taken 79120 times.
219096 if(misc==0)
7388 {
7389 79120 tile += f2;
7390 79120 }
7391
2/2
✓ Branch 0 taken 73149 times.
✓ Branch 1 taken 66827 times.
139976 else if(misc!=1)
7392 {
7393 66827 ++tile;
7394 66827 }
7395 }
7396 219096 break;
7397
7398 case aNEWTEK:
7399 {
7400
2/2
✓ Branch 0 taken 475246 times.
✓ Branch 1 taken 1343058 times.
1818304 if(step<0) //up
7401 {
7402
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235369 times.
✓ Branch 2 taken 239877 times.
475246 switch(clk3)
7403 {
7404 case left:
7405 235369 flip=0;
7406 235369 tile+=20;
7407 235369 break;
7408
7409 case right:
7410 239877 flip=0;
7411 239877 tile+=24;
7412 239877 break;
7413 }
7414 475246 }
7415
2/2
✓ Branch 0 taken 54749 times.
✓ Branch 1 taken 1288309 times.
1343058 else if(step==0)
7416 {
7417
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40566 times.
✓ Branch 2 taken 14183 times.
54749 switch(clk3)
7418 {
7419 case left:
7420 40566 flip=0;
7421 40566 tile+=8;
7422 40566 break;
7423
7424 case right:
7425 14183 flip=0;
7426 14183 tile+=12;
7427 14183 break;
7428 }
7429 54749 } //down
7430 else
7431 {
7432
3/3
✓ Branch 0 taken 109149 times.
✓ Branch 1 taken 593340 times.
✓ Branch 2 taken 585820 times.
1288309 switch(clk3)
7433 {
7434 case left:
7435 593340 flip=0;
7436 593340 tile+=28;
7437 593340 break;
7438
7439 case right:
7440 585820 flip=0;
7441 585820 tile+=32;
7442 585820 break;
7443 }
7444 }
7445
7446
2/2
✓ Branch 0 taken 1238755 times.
✓ Branch 1 taken 579549 times.
1818304 if(misc==0)
7447 {
7448 579549 tile+=f4;
7449 579549 }
7450
2/2
✓ Branch 0 taken 582085 times.
✓ Branch 1 taken 656670 times.
1238755 else if(misc!=1)
7451 {
7452 656670 tile+=2;
7453 656670 }
7454 }
7455 1818304 break;
7456
7457 case aARMOS:
7458 {
7459
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7460 {
7461 5401 tile += fx;
7462
7463
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7464 1197 tile += 2;
7465 5401 }
7466 }
7467 8628 break;
7468
7469 case aARMOS4:
7470 {
7471
5/5
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 29165 times.
✓ Branch 2 taken 92624 times.
✓ Branch 3 taken 43654 times.
✓ Branch 4 taken 43190 times.
209083 switch(dir)
7472 {
7473 case up:
7474 29165 flip=0;
7475 29165 break;
7476
7477 case down:
7478 92624 flip=0;
7479 92624 tile+=4;
7480 92624 break;
7481
7482 case left:
7483 43654 flip=0;
7484 43654 tile+=8;
7485 43654 break;
7486
7487 case right:
7488 43190 flip=0;
7489 43190 tile+=12;
7490 43190 break;
7491 }
7492
7493
2/2
✓ Branch 0 taken 63155 times.
✓ Branch 1 taken 145928 times.
209083 if(!fading)
7494 {
7495 145928 tile+=f4;
7496 145928 }
7497 }
7498 209083 break;
7499
7500 case aGHINI:
7501 {
7502
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7503 {
7504 case 8:
7505 case 9:
7506 case up:
7507 28037 ++tile;
7508 28037 flip=0;
7509 28037 break;
7510
7511 case 15:
7512 452 ++tile;
7513 452 flip=1;
7514 452 break;
7515
7516 case 10:
7517 case 11:
7518 case right:
7519 32092 flip=1;
7520 32092 break;
7521
7522 default:
7523 72763 flip=0;
7524 72763 break;
7525 }
7526 }
7527 133344 break;
7528
7529 case a2FRMPOS:
7530 {
7531 1755010 tile+=posframe;
7532 }
7533 1755010 break;
7534
7535 case a4FRMPOS4DIR:
7536 {
7537 363745 basetile = n_frame_n_dir(4,4,0);
7538 // tile+=f2;
7539 363745 tile+=posframe;
7540 }
7541 363745 break;
7542
7543 case a4FRMPOS4DIRF:
7544 {
7545 1433 basetile = n_frame_n_dir(4,4,0);
7546
7547
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7548 {
7549 197 tile+=20;
7550
7551
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7552 {
7553 64 tile+=20;
7554 64 }
7555 197 }
7556
7557 // tile+=f2;
7558 1433 tile+=posframe;
7559 }
7560 1433 break;
7561
7562 case a4FRMPOS8DIR:
7563 {
7564 7018408 tilerows = 2;
7565 7018408 int32_t n = tile;
7566 7018408 basetile = n_frame_n_dir(4,8,0);
7567 // tile+=f2;
7568 7018408 tile+=posframe;
7569 }
7570 7018408 break;
7571
7572 case a4FRMPOS8DIRF:
7573 {
7574 tilerows = 2;
7575 basetile = n_frame_n_dir(4,8,0);
7576
7577 if(clk2>0) //stopped to fire
7578 {
7579 tile+=40;
7580
7581 if(clk2<17) //firing
7582 {
7583 tile+=40;
7584 }
7585 }
7586
7587 tile+=posframe;
7588 }
7589 break;
7590
7591 case aNEWLEV:
7592 {
7593 747030 tiledir(dir,true);
7594
7595
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7596 {
7597 case -1:
7598 case 0:
7599 258994 return;
7600
7601 case 1:
7602
7603 // case 5: cs = d->misc2; break;
7604 case 5:
7605 115368 cs = dmisc2;
7606 115368 break;
7607
7608 case 2:
7609 case 4:
7610 48980 tile += 20;
7611 48980 break;
7612
7613 case 3:
7614 323688 tile += 40;
7615 323688 break;
7616 }
7617
7618 488036 tile+=f4;
7619 }
7620 488036 break;
7621
7622 case aLEV:
7623 {
7624 276997 f4 = ((clk/5)&1);
7625
7626
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7627 {
7628 case -1:
7629 case 0:
7630 127945 return;
7631
7632 case 1:
7633
7634 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7635 case 5:
7636 33336 tile += (f2) ? 1 : 0;
7637 33336 cs = dmisc2;
7638 33336 break;
7639
7640 case 2:
7641 case 4:
7642 14658 tile += 2;
7643 14658 break;
7644
7645 case 3:
7646 101058 tile += (f4) ? 4 : 3;
7647 101058 break;
7648 }
7649 }
7650 149052 break;
7651
7652 case aWALLM:
7653 {
7654
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7655 {
7656 139764 tile += f2;
7657 139764 }
7658 }
7659 140514 break;
7660
7661 case aNEWWALLM:
7662 {
7663 366633 int32_t tempdir=0;
7664
7665
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7666 {
7667 case 1:
7668 case 2:
7669 43340 tempdir=clk3;
7670 43340 break;
7671
7672 case 3:
7673 case 4:
7674 case 5:
7675 38855 tempdir=dir;
7676 38855 break;
7677
7678 case 6:
7679 case 7:
7680 8438 tempdir=clk3^1;
7681 8438 break;
7682 }
7683
7684 366633 tiledir(tempdir,true);
7685
7686
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7687 {
7688 364725 tile+=f4;
7689 364725 }
7690 }
7691 366633 break;
7692
7693 case a4FRMNODIR:
7694 {
7695 171508 tile+=f4;
7696 }
7697 171508 break;
7698
7699 } // switch(d->anim)
7700
7701 // flashing
7702 // if(d->flags & guy_flashing)
7703
2/2
✓ Branch 0 taken 39025400 times.
✓ Branch 1 taken 747549 times.
39772949 if(flags & guy_flashing)
7704 {
7705 747549 cs = (frame&3) + 6;
7706 747549 }
7707
7708
2/2
✓ Branch 0 taken 39362001 times.
✓ Branch 1 taken 410948 times.
39772949 if(flags&guy_transparent)
7709 {
7710 410948 drawstyle=1;
7711 410948 }
7712
7713 39772949 int32_t change = tile-basetile;
7714
7715
3/6
✓ Branch 0 taken 2054943 times.
✓ Branch 1 taken 37718006 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2054943 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39772949 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7716 {
7717
2/2
✓ Branch 0 taken 1792915 times.
✓ Branch 1 taken 262028 times.
2054943 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7718 {
7719 1792915 tile=basetile+txsz*change;
7720 1792915 }
7721 else
7722 {
7723 262028 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7724 }
7725 2054943 }
7726 else
7727 {
7728 37718006 tile=basetile+change;
7729 }
7730 40162270 }
7731
7732 81099 int32_t enemy::wpnsfx(int32_t wpn)
7733 {
7734
3/3
✓ Branch 0 taken 22419 times.
✓ Branch 1 taken 40973 times.
✓ Branch 2 taken 17707 times.
81099 switch (wpn)
7735 {
7736 case wScript1:
7737 case wScript2:
7738 case wScript3:
7739 case wScript4:
7740 case wScript5:
7741 case wScript6:
7742 case wScript7:
7743 case wScript8:
7744 case wScript9:
7745 case wScript10: //sure why not
7746 case ewFireTrail:
7747 case ewFlame:
7748 case ewFlame2Trail:
7749 case ewFlame2:
7750 case ewWind:
7751 case ewMagic:
7752 case ewIce:
7753 22419 return firesfx;
7754
7755 case ewRock:
7756 case ewFireball2:
7757 case ewFireball:
7758
2/2
✓ Branch 0 taken 5530 times.
✓ Branch 1 taken 35443 times.
40973 if (get_qr(qr_MORESOUNDS)) return firesfx;
7759 35443 break;
7760 }
7761
7762 53150 return 0;
7763 81099 }
7764
7765 77039593 int32_t enemy::run_script(int32_t mode)
7766 {
7767 void push_ri();
7768 void pop_ri();
7769
7770
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 77039337 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
77039593 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7771
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 77039337 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
77039337 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7772 77039337 return RUNSCRIPT_OK;
7773 auto scrty = *get_scrtype();
7774 auto uid = getUID();
7775 if(!FFCore.doscript(scrty,uid))
7776 return RUNSCRIPT_OK;
7777 int32_t ret = RUNSCRIPT_OK;
7778 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7779 push_ri();
7780 switch(mode)
7781 {
7782 case MODE_NORMAL:
7783 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7784 break;
7785
7786 case MODE_WAITDRAW:
7787 if(waitdraw)
7788 {
7789 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7790 waitdraw = false;
7791 }
7792 break;
7793 }
7794 pop_ri();
7795 return ret;
7796 77039593 }
7797 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7798 {
7799 return al_map_rgba(255,0,0,opacity);
7800 }
7801
7802 // good guys, fires, fairy, and other non-enemies
7803 // based on enemy class b/c guys in dungeons act sort of like enemies
7804 // also easier to manage all the guys this way
7805 2191 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7806 2191 {
7807 2191 mainguy=mg;
7808 2191 canfreeze=false;
7809 2191 dir=down;
7810
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2191 times.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
2191 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7811 2191 hxofs=2;
7812 2191 hzsz=8;
7813 2191 hit_width=12;
7814 2191 hit_height=17;
7815
7816
10/12
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1426 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2191 if(!superman && (!isdungeon(screen_spawned) || id==gFAIRY || id==gFIRE || id==gZELDA))
7817 {
7818 1931 superman = 1;
7819 1931 hxofs=1000;
7820 1931 }
7821 2191 }
7822
7823 943762 bool guy::animate(int32_t index)
7824 {
7825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 943762 times.
943762 if(switch_hooked) return enemy::animate(index);
7826
6/6
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 8298 times.
✓ Branch 3 taken 534894 times.
✓ Branch 4 taken 7092 times.
✓ Branch 5 taken 1206 times.
943762 if(mainguy && clk==0 && misc==0)
7827 {
7828 1206 setupscreen();
7829 1206 misc = 1;
7830 1206 }
7831
7832
4/4
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 542862 times.
✓ Branch 3 taken 330 times.
943762 if(mainguy && fadeclk==0)
7833 330 return true;
7834
7835 943432 hp=256; // good guys never die...
7836
7837
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 942510 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
943432 if(hclk && !clk2)
7838 {
7839 // but if they get hit...
7840 16 ++clk2; // only do this once
7841
7842
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7843 {
7844 7 addenemy(screen_spawned,BSZ?64:72,68,eSHOOTFBALL,0);
7845 7 addenemy(screen_spawned,BSZ?176:168,68,eSHOOTFBALL,0);
7846 7 }
7847 16 }
7848
7849 943432 return enemy::animate(index);
7850 943762 }
7851
7852 947535 void guy::draw(BITMAP *dest)
7853 {
7854 947535 update_enemy_frame();
7855
7856
6/6
✓ Branch 0 taken 546756 times.
✓ Branch 1 taken 400779 times.
✓ Branch 2 taken 22911 times.
✓ Branch 3 taken 523845 times.
✓ Branch 4 taken 11064 times.
✓ Branch 5 taken 11847 times.
947535 if(!mainguy || fadeclk<0 || fadeclk&1)
7857 935688 enemy::draw(dest);
7858 947535 }
7859
7860 760 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7861 760 {
7862 760 clk4=0;
7863
4/8
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 760 times.
✗ Branch 7 not taken.
760 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7864 // Spawn type
7865
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(flags & guy_fade_flicker)
7866 {
7867 clk=0;
7868 superman = 1;
7869 fading=fade_flicker;
7870 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7871 dir=down;
7872
7873 if(!canmove(down,(zfix)8,spw_none,false))
7874 clk3=int32_t(13.0/step);
7875 }
7876
3/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 84 times.
760 else if(flags & guy_fade_instant)
7877 {
7878 84 clk=0;
7879 84 }
7880
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if (SIZEflags != 0) init_size_flags();;
7881 760 }
7882
7883 167472 bool eFire::animate(int32_t index)
7884 {
7885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167472 times.
167472 if(switch_hooked) return enemy::animate(index);
7886
2/4
✓ Branch 0 taken 167472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167472 times.
167472 if(fallclk||drownclk) return enemy::animate(index);
7887
2/2
✓ Branch 0 taken 165756 times.
✓ Branch 1 taken 1716 times.
167472 if(fading)
7888 {
7889
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7890 {
7891 1 clk4=0;
7892 1 superman=0;
7893 1 fading=0;
7894
7895
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7896 removearmos(x,y,ffcactivated);
7897
7898 1 clk2=0;
7899
7900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7901 {
7902 1 dir=0;
7903 1 y = TRUNCATE_TILE(y.getInt());
7904 1 }
7905
7906 1 return Dead(index);
7907 }
7908
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7909 removearmos(x,y,ffcactivated);
7910 1715 }
7911
7912 167471 return enemy::animate(index);
7913 167472 }
7914
7915 351659 void eFire::draw(BITMAP *dest)
7916 {
7917 351659 update_enemy_frame();
7918 351659 enemy::draw(dest);
7919 351659 }
7920
7921 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7922 {
7923 415 int32_t wpnId = w->id;
7924 415 int32_t wpnDir = w->dir;
7925
7926
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7927 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7928 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7929 {
7930 shield = false;
7931 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7932
7933 if(get_qr(qr_BRKNSHLDTILES))
7934 o_tile=s_tile;
7935 }
7936
7937 415 int32_t ret = enemy::takehit(w,realweap);
7938 415 return ret;
7939 }
7940
7941 void eFire::break_shield()
7942 {
7943 if(!shield)
7944 return;
7945
7946 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7947 shield=false;
7948
7949 if(get_qr(qr_BRKNSHLDTILES))
7950 o_tile=s_tile;
7951 }
7952
7953 void eFire::repair_shield()
7954 {
7955 if (shield)
7956 return;
7957
7958 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7959 return;
7960
7961 shield = true;
7962
7963 if (get_qr(qr_BRKNSHLDTILES))
7964 {
7965 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7966 else o_tile = d->tile;
7967 }
7968 }
7969
7970 7630 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7971 7630 {
7972 7630 clk4=0;
7973
4/8
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7630 times.
✗ Branch 7 not taken.
7630 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7974
7975 // Spawn type
7976
2/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7630 times.
7630 if(flags & guy_fade_flicker)
7977 {
7978 clk=0;
7979 superman = 1;
7980 fading=fade_flicker;
7981 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7982 dir=down;
7983
7984 if(!canmove(down,(zfix)8,spw_none,false))
7985 clk3=int32_t(13.0/step);
7986 }
7987
3/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6443 times.
✓ Branch 3 taken 1187 times.
7630 else if(flags & guy_fade_instant)
7988 {
7989 1187 clk=0;
7990 1187 }
7991
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7623 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7630 if (SIZEflags != 0) init_size_flags();;
7992 7630 }
7993
7994 1981512 bool eOther::animate(int32_t index)
7995 {
7996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981512 times.
1981512 if(switch_hooked) return enemy::animate(index);
7997
3/4
✓ Branch 0 taken 1979926 times.
✓ Branch 1 taken 1586 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1979926 times.
1981512 if(fallclk||drownclk) return enemy::animate(index);
7998
2/2
✓ Branch 0 taken 1971390 times.
✓ Branch 1 taken 8536 times.
1979926 if(fading)
7999 {
8000
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 8507 times.
8536 if(++clk4 > 60)
8001 {
8002 29 clk4=0;
8003 29 superman=0;
8004 29 fading=0;
8005
8006
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29 if(flags&guy_armos && z==0 && fakez==0)
8007 removearmos(x,y,ffcactivated);
8008
8009 29 clk2=0;
8010
8011
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2 times.
29 if(!canmove(down,(zfix)8,spw_none,false))
8012 {
8013 2 dir=0;
8014 2 y = TRUNCATE_TILE(y.getInt());
8015 2 }
8016
8017 29 return Dead(index);
8018 }
8019
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8507 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8020 removearmos(x,y,ffcactivated);
8021 8507 }
8022
8023 1979897 return enemy::animate(index);
8024 1981512 }
8025
8026 2087673 void eOther::draw(BITMAP *dest)
8027 {
8028 2087673 update_enemy_frame();
8029 2087673 enemy::draw(dest);
8030 2087673 }
8031
8032 14773 int32_t eOther::takehit(weapon *w, weapon* realweap)
8033 {
8034 14773 int32_t wpnId = w->id;
8035 14773 int32_t wpnDir = w->dir;
8036
8037
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14731 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
14773 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8038 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8039 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8040 {
8041 shield = false;
8042 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8043
8044 if(get_qr(qr_BRKNSHLDTILES))
8045 o_tile=s_tile;
8046 }
8047
8048 14773 int32_t ret = enemy::takehit(w,realweap);
8049 14773 return ret;
8050 }
8051
8052 void eOther::break_shield()
8053 {
8054 if(!shield)
8055 return;
8056
8057 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8058 shield=false;
8059
8060 if(get_qr(qr_BRKNSHLDTILES))
8061 o_tile=s_tile;
8062 }
8063
8064 void eOther::repair_shield()
8065 {
8066 if (shield)
8067 return;
8068
8069 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8070 return;
8071
8072 shield = true;
8073
8074 if (get_qr(qr_BRKNSHLDTILES))
8075 {
8076 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8077 else o_tile = d->tile;
8078 }
8079 }
8080
8081 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8082 {
8083 clk4=0;
8084 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8085
8086 // Spawn type
8087 if(flags & guy_fade_flicker)
8088 {
8089 clk=0;
8090 superman = 1;
8091 fading=fade_flicker;
8092 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8093 dir=down;
8094
8095 if(!canmove(down,(zfix)8,spw_none,false))
8096 clk3=int32_t(13.0/step);
8097 }
8098 else if(flags & guy_fade_instant)
8099 {
8100 clk=0;
8101 }
8102 if (SIZEflags != 0) init_size_flags();;
8103 }
8104
8105 bool eScript::animate(int32_t index)
8106 {
8107 if(switch_hooked) return enemy::animate(index);
8108 if(fallclk||drownclk) return enemy::animate(index);
8109 if(fading)
8110 {
8111 if(++clk4 > 60)
8112 {
8113 clk4=0;
8114 superman=0;
8115 fading=0;
8116
8117 if(flags&guy_armos && z==0 && fakez==0)
8118 removearmos(x,y,ffcactivated);
8119
8120 clk2=0;
8121
8122 if(!canmove(down,(zfix)8,spw_none,false))
8123 {
8124 dir=0;
8125 y = TRUNCATE_TILE(y.getInt());
8126 }
8127
8128 return Dead(index);
8129 }
8130 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8131 removearmos(x,y,ffcactivated);
8132 }
8133
8134 return enemy::animate(index);
8135 }
8136
8137 void eScript::draw(BITMAP *dest)
8138 {
8139 update_enemy_frame();
8140 enemy::draw(dest);
8141 }
8142
8143 int32_t eScript::takehit(weapon *w, weapon* realweap)
8144 {
8145 int32_t wpnId = w->id;
8146 int32_t wpnDir = w->dir;
8147
8148 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8149 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8150 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8151 {
8152 shield = false;
8153 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8154
8155 if(get_qr(qr_BRKNSHLDTILES))
8156 o_tile=s_tile;
8157 }
8158
8159 int32_t ret = enemy::takehit(w,realweap);
8160 return ret;
8161 }
8162
8163 void eScript::break_shield()
8164 {
8165 if(!shield)
8166 return;
8167
8168 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8169 shield=false;
8170
8171 if(get_qr(qr_BRKNSHLDTILES))
8172 o_tile=s_tile;
8173 }
8174
8175 void eScript::repair_shield()
8176 {
8177 if (shield)
8178 return;
8179
8180 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8181 return;
8182
8183 shield = true;
8184
8185 if (get_qr(qr_BRKNSHLDTILES))
8186 {
8187 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8188 else o_tile = d->tile;
8189 }
8190 }
8191
8192
8193 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8194 {
8195 clk4=0;
8196 hyofs = -32768; //No hitbox initially.
8197 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8198
8199 // Spawn type
8200 if(flags & guy_fade_flicker)
8201 {
8202 clk=0;
8203 superman = 1;
8204 fading=fade_flicker;
8205 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8206 dir=down;
8207
8208 if(!canmove(down,(zfix)8,spw_none,false))
8209 clk3=int32_t(13.0/step);
8210 }
8211 else if(flags & guy_fade_instant)
8212 {
8213 clk=0;
8214 }
8215 if (SIZEflags != 0) init_size_flags();;
8216 }
8217
8218 bool eFriendly::animate(int32_t index)
8219 {
8220 if(switch_hooked) return enemy::animate(index);
8221 if(fallclk||drownclk) return enemy::animate(index);
8222 if(fading)
8223 {
8224 if(++clk4 > 60)
8225 {
8226 clk4=0;
8227 superman=0;
8228 fading=0;
8229
8230 if(flags&guy_armos && z==0 && fakez==0)
8231 removearmos(x,y,ffcactivated);
8232
8233 clk2=0;
8234
8235 if(!canmove(down,(zfix)8,spw_none,false))
8236 {
8237 dir=0;
8238 y = TRUNCATE_TILE(y.getInt());
8239 }
8240
8241 return Dead(index);
8242 }
8243 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8244 removearmos(x,y,ffcactivated);
8245 }
8246
8247 return enemy::animate(index);
8248 }
8249
8250 void eFriendly::draw(BITMAP *dest)
8251 {
8252 update_enemy_frame();
8253 enemy::draw(dest);
8254 }
8255
8256 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8257 {
8258 int32_t wpnId = w->id;
8259 int32_t wpnDir = w->dir;
8260
8261 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8262 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8263 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8264 {
8265 shield = false;
8266 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8267
8268 if(get_qr(qr_BRKNSHLDTILES))
8269 o_tile=s_tile;
8270 }
8271
8272 int32_t ret = enemy::takehit(w,realweap);
8273 return ret;
8274 }
8275
8276 void eFriendly::break_shield()
8277 {
8278 if(!shield)
8279 return;
8280
8281 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8282 shield=false;
8283
8284 if(get_qr(qr_BRKNSHLDTILES))
8285 o_tile=s_tile;
8286 }
8287
8288 void eFriendly::repair_shield()
8289 {
8290 if (shield)
8291 return;
8292
8293 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8294 return;
8295
8296 shield = true;
8297
8298 if (get_qr(qr_BRKNSHLDTILES))
8299 {
8300 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8301 else o_tile = d->tile;
8302 }
8303 }
8304
8305
8306 780024 void enemy::removearmos(int32_t ax,int32_t ay, std::optional<ffc_handle_t> ffcactive)
8307 {
8308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780024 times.
780024 if (ffcactive)
8309 {
8310 removearmosffc(*ffcactive);
8311 return;
8312 }
8313
2/2
✓ Branch 0 taken 779008 times.
✓ Branch 1 taken 1016 times.
780024 if(did_armos)
8314 {
8315 779008 return;
8316 }
8317
8318 1016 auto rpos_handle = get_rpos_handle_for_world_xy(ax, ay, 0);
8319 1016 mapscr* scr = rpos_handle.scr;
8320 1016 ax = TRUNCATE_TILE(ax);
8321 1016 ay = TRUNCATE_TILE(ay);
8322
8323 1016 did_armos=true;
8324 1016 int32_t cd = rpos_handle.pos;
8325 1016 int32_t f = rpos_handle.sflag();
8326 1016 int32_t f2 = rpos_handle.cflag();
8327
8328
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 176 times.
1016 if (rpos_handle.ctype() != cARMOS)
8329 {
8330 840 return;
8331 }
8332
8333 176 scr->data[cd] = scr->undercombo;
8334 176 scr->cset[cd] = scr->undercset;
8335 176 scr->sflag[cd] = 0;
8336
8337
3/4
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154 times.
176 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8338 {
8339 22 scr->data[cd] = scr->secretcombo[sSTAIRS];
8340 22 scr->cset[cd] = scr->secretcset[sSTAIRS];
8341 22 scr->sflag[cd]=scr->secretflag[sSTAIRS];
8342 22 sfx(scr->secretsfx);
8343 22 }
8344
8345
3/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
176 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8346 {
8347
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8348 {
8349 3 additem(ax,ay,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8350 3 sfx(scr->secretsfx);
8351 3 }
8352 3 }
8353
8354 176 putcombo(scrollbuf,ax,ay,scr->data[cd],scr->cset[cd]);
8355 780024 }
8356
8357 void enemy::removearmosffc(const ffc_handle_t& ffc_handle)
8358 {
8359 if(did_armos)
8360 {
8361 return;
8362 }
8363
8364 did_armos=true;
8365 ffcdata& ffc = *ffc_handle.ffc;
8366 mapscr* scr = ffc_handle.scr;
8367 auto& cmb = ffc_handle.combo();
8368 int32_t f2 = cmb.flag;
8369
8370 if(cmb.type!=cARMOS)
8371 {
8372 return;
8373 }
8374
8375 ffc_handle.set_data(scr->undercombo);
8376 ffc_handle.set_cset(scr->undercset);
8377
8378 if(f2 == mfARMOS_SECRET)
8379 {
8380 ffc_handle.set_data(scr->secretcombo[sSTAIRS]);
8381 ffc_handle.set_cset(scr->secretcset[sSTAIRS]);
8382 sfx(scr->secretsfx);
8383 }
8384
8385 if(f2 == mfARMOS_ITEM)
8386 {
8387 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8388 {
8389 additem(ffc.x,ffc.y,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8390 sfx(scr->secretsfx);
8391 }
8392 }
8393
8394 putcombo(scrollbuf,ffc.x,ffc.y,ffc_handle.data(),ffc.cset);
8395 }
8396
8397
8398 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8399 461 {
8400 461 fading=fade_flicker;
8401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8402 461 dir=12;
8403 461 movestatus=1;
8404
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8405 461 clk=0;
8406 461 clk4=0;
8407
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8408 461 }
8409
8410 117025 bool eGhini::animate(int32_t index)
8411 {
8412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8413
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8414
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8415 50 return Dead(index);
8416
8417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8418 {
8419
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8420 {
8421
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8422 54853 misc=2;
8423
8424
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8425 89752 removearmos(x,y,ffcactivated);
8426 89752 }
8427
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8428 {
8429 425 misc=1;
8430 425 clk3=32;
8431 425 fading=0;
8432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if (ffcactivated)
8433 {
8434 activation_counters_ffc[ffcactivated->id] = 0;
8435 removearmosffc(*ffcactivated);
8436 }
8437 else
8438 {
8439 425 rpos_t rpos = COMBOPOS_REGION_B(x, y);
8440
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if (rpos != rpos_t::None)
8441 {
8442 425 activation_counters[(int)rpos] = 0;
8443 425 removearmos(x,y);
8444 425 }
8445 }
8446 425 }
8447 116975 }
8448
8449 116975 clk4++;
8450
8451 116975 return enemy::animate(index);
8452 117025 }
8453
8454 238808 void eGhini::draw(BITMAP *dest)
8455 {
8456 238808 update_enemy_frame();
8457 238808 enemy::draw(dest);
8458 238808 }
8459
8460 2 void eGhini::kickbucket()
8461 {
8462 2 hp=-1000; // don't call death_sfx()
8463 2 }
8464
8465
2/4
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
10424 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8466 5212 {
8467
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 old_y=y;
8468 5212 dir=down;
8469 5212 misc=1;
8470 5212 clk=-15;
8471
8472
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 2563 times.
5212 if(!BSZ)
8473
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 clk*=zc_oldrand()%3+1;
8474
8475 // avoid divide by 0 errors
8476
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc1 == 0)
8477 dmisc1 = 24;
8478
8479
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc2 == 0)
8480 dmisc2 = 3;
8481
8482 //nets+760;
8483
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5212 if (SIZEflags != 0) init_size_flags();;
8484 5212 }
8485
8486 1436598 bool eTektite::animate(int32_t index)
8487 {
8488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1436598 times.
1436598 if(switch_hooked) return enemy::animate(index);
8489
4/4
✓ Branch 0 taken 1427644 times.
✓ Branch 1 taken 8954 times.
✓ Branch 2 taken 8954 times.
✓ Branch 3 taken 1425286 times.
1436598 if(fallclk||drownclk) return enemy::animate(index);
8490
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1398619 times.
1425286 if(dying)
8491 26667 return Dead(index);
8492
8493
2/2
✓ Branch 0 taken 1361516 times.
✓ Branch 1 taken 37103 times.
1398619 if(clk==0)
8494 {
8495 37103 removearmos(x,y,ffcactivated);
8496 37103 }
8497
8498
2/2
✓ Branch 0 taken 1057436 times.
✓ Branch 1 taken 341183 times.
1398619 if(get_qr(qr_ENEMIESZAXIS))
8499 {
8500 341183 y=floor_y;
8501 341183 }
8502
8503
9/10
✓ Branch 0 taken 1283739 times.
✓ Branch 1 taken 114880 times.
✓ Branch 2 taken 1270175 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1270175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1258999 times.
✓ Branch 8 taken 11916 times.
✓ Branch 9 taken 21878 times.
1398619 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8504 {
8505
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421702 times.
✓ Branch 2 taken 345150 times.
✓ Branch 3 taken 493765 times.
1280877 switch(misc)
8506 {
8507 case 0: // normal
8508
2/2
✓ Branch 0 taken 410469 times.
✓ Branch 1 taken 11233 times.
421702 if (!zc::math::SafeMod(zc_oldrand(), dmisc1))
8509 {
8510 11233 misc=1;
8511 11233 clk2=32;
8512 11233 }
8513
8514 421702 break;
8515
8516 case 1: // waiting to pounce
8517
2/2
✓ Branch 0 taken 324515 times.
✓ Branch 1 taken 20635 times.
345150 if(--clk2<=0)
8518 {
8519 20635 int32_t r=zc_oldrand();
8520 20635 misc=2;
8521 20635 step=0-(zslongToFix(dstep*100)); // initial speed
8522 20635 clk3=(r&1)+2; // left or right
8523 20635 clk2start=clk2=(r&31)+10; // flight time
8524
8525
2/2
✓ Branch 0 taken 18212 times.
✓ Branch 1 taken 2423 times.
20635 if(y<32) clk2+=2; // make them come down from top of screen
8526
8527
2/2
✓ Branch 0 taken 15717 times.
✓ Branch 1 taken 4918 times.
20635 if(y>world_h-64) clk2-=2; // make them go back up
8528
8529 20635 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8530 20635 }
8531
8532 345150 break;
8533
8534 case 2: // in flight
8535 493765 move(step);
8536
8537
2/2
✓ Branch 0 taken 234357 times.
✓ Branch 1 taken 259408 times.
493765 if(step>0) //going down
8538 {
8539
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233725 times.
234357 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8540 {
8541 632 step=0-step;
8542 632 }
8543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8544 {
8545 step=0-step;
8546 }
8547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(ispitfall(x+8,y+16))
8548 {
8549 step=0-step;
8550 }
8551
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233678 times.
233725 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8552 {
8553 47 step=0-step;
8554 47 }
8555
2/2
✓ Branch 0 taken 233667 times.
✓ Branch 1 taken 11 times.
233678 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8556 {
8557 11 step=0-step;
8558 11 }
8559 234357 }
8560
2/2
✓ Branch 0 taken 15166 times.
✓ Branch 1 taken 244242 times.
259408 else if(step<0)
8561 {
8562
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243804 times.
244242 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8563 {
8564 438 step=0-step;
8565 438 }
8566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8567 {
8568 step=0-step;
8569 }
8570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(ispitfall(x+8,y))
8571 {
8572 step=0-step;
8573 }
8574
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243783 times.
243804 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8575 {
8576 21 step=0-step;
8577 21 }
8578
2/2
✓ Branch 0 taken 243764 times.
✓ Branch 1 taken 19 times.
243783 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8579 {
8580 19 step=0-step;
8581 19 }
8582 244242 }
8583
8584
2/2
✓ Branch 0 taken 244331 times.
✓ Branch 1 taken 249434 times.
493765 if(clk3==left)
8585 {
8586
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 244056 times.
244331 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8587 {
8588 275 clk3^=1;
8589 275 }
8590
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 244050 times.
244056 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8591 {
8592 6 clk3^=1;
8593 6 }
8594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244050 times.
244050 else if(ispitfall(x,y+8))
8595 {
8596 clk3^=1;
8597 }
8598
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 244020 times.
244050 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8599 {
8600 30 clk3^=1;
8601 30 }
8602
2/2
✓ Branch 0 taken 244008 times.
✓ Branch 1 taken 12 times.
244020 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8603 {
8604 12 clk3^=1;
8605 12 }
8606 244331 }
8607 else
8608 {
8609
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 249158 times.
249434 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8610 {
8611 276 clk3^=1;
8612 276 }
8613
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 249146 times.
249158 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8614 {
8615 12 clk3^=1;
8616 12 }
8617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249146 times.
249146 else if(ispitfall(x+16,y+8))
8618 {
8619 clk3^=1;
8620 }
8621
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 249141 times.
249146 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8622 {
8623 5 clk3^=1;
8624 5 }
8625
2/2
✓ Branch 0 taken 249129 times.
✓ Branch 1 taken 12 times.
249141 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8626 {
8627 12 clk3^=1;
8628 12 }
8629 }
8630
8631 493765 --c;
8632
8633
4/4
✓ Branch 0 taken 151531 times.
✓ Branch 1 taken 342234 times.
✓ Branch 2 taken 320688 times.
✓ Branch 3 taken 173077 times.
493765 if(c<0 && step<zslongToFix(dstep*100))
8634 {
8635 173077 step+=zslongToFix(dmisc3*100);
8636 173077 }
8637
8638 493765 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8639
8640
2/2
✓ Branch 0 taken 493043 times.
✓ Branch 1 taken 722 times.
493765 if(x<=16-nb) clk3=right;
8641
8642
2/2
✓ Branch 0 taken 492773 times.
✓ Branch 1 taken 992 times.
493765 if(x>=world_w-32+nb) clk3=left;
8643
8644 493765 x += (clk3==left) ? -1 : 1;
8645
8646
4/4
✓ Branch 0 taken 29039 times.
✓ Branch 1 taken 464726 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454596 times.
493765 if((--clk2<=0 && y>=16-nb) || y>=world_h-32+nb)
8647 {
8648
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17288 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39169 if(y>=world_h-32+nb && get_qr(qr_ENEMIESZAXIS))
8649 {
8650 185 step=0-step;
8651 185 y--;
8652 185 }
8653
2/2
✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 12928 times.
18724 else if (zc::math::SafeMod(zc_oldrand(), dmisc2)) //land and wait
8654 {
8655 12928 clk=misc=0;
8656 12928 } //land and jump again
8657 else
8658 {
8659 5796 misc=1;
8660 5796 clk2=0;
8661 }
8662 18909 }
8663
8664 473505 break;
8665 } // switch
8666 1260617 }
8667
8668
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1059794 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1400977 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8669 {
8670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8671 {
8672 int32_t tempy = floor_y;
8673 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8674 floor_y = y;
8675 y=tempy-fakez;
8676 old_y = y;
8677 }
8678 else
8679 {
8680 109977 int32_t tempy = floor_y;
8681
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8682 109977 floor_y = y;
8683 109977 y=tempy-z;
8684 109977 old_y = y;
8685 }
8686 109977 }
8687
8688
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1387413 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1400977 if(stunclk && (clk&31)==1)
8689 10637 clk=0;
8690
8691 1400977 return enemy::animate(index);
8692 1427644 }
8693
8694 809450 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8695 {
8696
5/6
✓ Branch 0 taken 632172 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 632172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 606981 times.
✓ Branch 5 taken 25191 times.
809450 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8697 25191 return;
8698
8699 784259 int32_t tempy=yofs;
8700 784259 int32_t fdiv = frate/4;
8701
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8702
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8703 784259 efrate:((clk>=(frate>>1))?1:0);
8704 784259 flip = 0;
8705 784259 shadowtile = wpnsbuf[spr_shadow].tile;
8706
8707
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 if(get_qr(qr_NEWENEMYTILES))
8708 {
8709
2/2
✓ Branch 0 taken 581728 times.
✓ Branch 1 taken 202531 times.
784259 if(misc==0)
8710 {
8711 202531 shadowtile+=f2;
8712 202531 }
8713
2/2
✓ Branch 0 taken 259363 times.
✓ Branch 1 taken 322365 times.
581728 else if(misc!=1)
8714 322365 shadowtile+=2;
8715 784259 }
8716 else
8717 {
8718 if(misc==0)
8719 {
8720 shadowtile += f2 ? 1 : 0;
8721 }
8722 else if(misc!=1)
8723 {
8724 ++shadowtile;
8725 }
8726 }
8727
8728 784259 yofs+=8;
8729
8730
4/4
✓ Branch 0 taken 606981 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 344816 times.
✓ Branch 3 taken 262165 times.
784259 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8731 {
8732
6/6
✓ Branch 0 taken 134327 times.
✓ Branch 1 taken 127838 times.
✓ Branch 2 taken 244709 times.
✓ Branch 3 taken 17456 times.
✓ Branch 4 taken 123717 times.
✓ Branch 5 taken 120992 times.
262165 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8733 262165 }
8734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784259 times.
784259 if(!shadow_overpit(this))
8735 784259 enemy::drawshadow(dest,translucent);
8736 784259 yofs=tempy;
8737 809450 }
8738
8739 2052032 void eTektite::draw(BITMAP *dest)
8740 {
8741 2052032 update_enemy_frame();
8742 2052032 enemy::draw(dest);
8743 2052032 }
8744
8745 732 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8746 732 {
8747
2/4
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
732 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8748 732 superman=1;
8749 732 dir=8;
8750 732 hxofs=1000;
8751 732 mainguy=false;
8752 732 count_enemy=false;
8753
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
732 if (SIZEflags != 0) init_size_flags();;
8754 732 }
8755
8756 280245 bool eItemFairy::animate(int32_t index)
8757 {
8758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(switch_hooked) return enemy::animate(index);
8759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(dying)
8760 return Dead(index);
8761
8762 //if(clk>32)
8763 280245 misc=1;
8764 280245 bool w=watch;
8765 280245 watch=false;
8766 280245 variable_walk_8(misc?3:0,0,8,spw_floater);
8767 280245 watch=w;
8768
8769
2/2
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 278729 times.
280245 if(clk==0)
8770 {
8771 1516 removearmos(x,y,ffcactivated);
8772 1516 }
8773
8774 280245 return enemy::animate(index);
8775 280245 }
8776
8777 562846 void eItemFairy::draw(BITMAP *dest)
8778 {
8779 //these are here to bypass compiler warnings about unused arguments
8780 562846 dest=dest;
8781 562846 }
8782
8783 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8784 1825 {
8785 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8786
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8787 1825 dir=8;
8788 1825 movestatus=1;
8789 1825 clk=0;
8790
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8791 //nets+720;
8792
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8793 1825 }
8794
8795 520615 bool ePeahat::animate(int32_t index)
8796 {
8797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8798
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8799
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8800 {
8801 78 return false;
8802 }
8803
8804
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8805 1030 return Dead(index);
8806
8807
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8808 {
8809 3083 removearmos(x,y,ffcactivated);
8810 3083 }
8811
8812
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8813 263053 misc=1;
8814
8815
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8816
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8817
8818
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8819 {
8820
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8821 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8822 100018 }
8823
8824
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8825 1634 superman=0;
8826 else
8827
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8828 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8829
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8830 {
8831
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8832 264937 }
8833 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8834 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8835
8836
8837
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8838
8839 519507 return enemy::animate(index);
8840 520615 }
8841
8842 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8843 {
8844 334520 int32_t tempy=yofs;
8845 334520 flip = 0;
8846 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8847
8848
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8849 {
8850 246431 yofs+=8;
8851 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8852 246431 }
8853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8854 334520 enemy::drawshadow(dest,translucent);
8855 334520 yofs=tempy;
8856 334520 }
8857
8858 1144330 void ePeahat::draw(BITMAP *dest)
8859 {
8860 1144330 update_enemy_frame();
8861 1144330 enemy::draw(dest);
8862 1144330 }
8863
8864 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8865 {
8866 4136 int32_t wpnId = w->id;
8867 4136 int32_t enemyHitWeapon = w->parentitem;
8868
8869
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8870 return 0;
8871
8872
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8873 // fire boomerang, for nailing peahats
8874
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8875 3343 return 0;
8876
8877 // Time for a kludge...
8878 793 int32_t s = superman;
8879 793 superman = 0;
8880 793 int32_t ret = enemy::takehit(w,realweap);
8881 793 superman = s;
8882
8883 // Anyway...
8884
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8885 {
8886 192 clk2=0;
8887 192 movestatus=0;
8888 192 misc=0;
8889 192 clk=0;
8890 192 step=0;
8891 192 }
8892
8893 793 return ret;
8894 4136 }
8895
8896 // auomatically kill off enemy (for rooms with ringleaders)
8897 void ePeahat::kickbucket()
8898 {
8899 hp=-1000; // don't call death_sfx()
8900 }
8901
8902 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8903 3942 {
8904 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8905
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8906 {
8907 2147 misc=-1; //Line of Sight leevers
8908 2147 clk-=16;
8909 2147 }
8910 3942 clk3 = 0;
8911 //nets+1460;
8912 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8913 3942 submerged = false;
8914
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8915 3942 }
8916
8917 923 bool eLeever::isSubmerged() const
8918 {
8919 923 return misc <= 0;
8920 }
8921
8922 1018478 bool eLeever::animate(int32_t index)
8923 {
8924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8925
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8926 {
8927 355 return enemy::animate(index);
8928 }
8929
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8930 31552 return Dead(index);
8931
8932
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8933 {
8934 44970 removearmos(x,y,ffcactivated);
8935 44970 }
8936
8937
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8938 {
8939
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8940 {
8941 case 0: //line of sight
8942 case 2:
8943
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8944 {
8945 case -1: //submerged
8946 {
8947
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8948
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8949 {
8950 10261 break;
8951 }
8952
8953 114198 int32_t active=0;
8954
8955
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8956 {
8957
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8958 {
8959 225696 ++active;
8960 225696 }
8961 783342 }
8962
8963
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8964 {
8965 1871 misc=0; //activate this one
8966 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8967 1871 }
8968 }
8969 114198 break;
8970
8971 case 0:
8972 {
8973
8974
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8975 {
8976 misc=1;
8977 clk2=0;
8978 }
8979
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8980 {
8981 57 misc = -1;
8982 57 break;
8983 }
8984 49052 int32_t s=0;
8985
8986
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8987 {
8988
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8989 {
8990 7882 ++s;
8991 7882 }
8992 273250 }
8993
8994
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
8995 {
8996 7882 break;
8997 }
8998
8999 41170 int32_t d2=zc_oldrand()&1;
9000
9001
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
9002 {
9003 26661 d2+=2;
9004 26661 }
9005
9006
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 663 times.
✓ Branch 3 taken 39059 times.
41170 if(canplace(d2) || canplace(d2^1))
9007 {
9008 2111 misc=1;
9009 2111 clk2=0;
9010 2111 clk=0;
9011 2111 }
9012 }
9013 41170 break;
9014
9015 case 1:
9016
9017
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9018
9019 35464 break;
9020
9021 case 2:
9022
9023
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9024
9025 15780 break;
9026
9027 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9028 case 3:
9029
9030
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
9031
9032
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
9033
9034
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
9035 94963 else move(zslongToFix(dstep*100));
9036
9037 95468 break;
9038
9039 case 4:
9040
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9041
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
9042 {
9043 468 misc=5;
9044 468 clk=8;
9045 468 }
9046
9047 4365 break;
9048
9049 case 5:
9050
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9051
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9052
9053 6907 break;
9054 } // switch(misc)
9055
9056 337868 break;
9057
9058 default: //random
9059 // step=d->misc3/100.0;
9060
9061 473814 step=zslongToFix(dmisc3*100);
9062
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9063 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9064 {
9065 if (clk2 < 48) clk2+=2;
9066 if (clk2 >= 300) clk2-=2;
9067 }
9068
9069
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
9070
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
9071
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
9072 {
9073 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9074 {
9075 fix_coords();
9076 }*/
9077 289541 misc=3;
9078 289541 step = zslongToFix(dstep*100);
9079 289541 }
9080
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
9081
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
9082
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
9083 {
9084 40151 misc=0;
9085 40151 step=0;
9086 40151 }
9087 274 else clk2=0;
9088
9089
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
9090
9091 // variable_walk(d->rate, d->homing, 0);
9092 473814 variable_walk(rate, homing, 0);
9093 473814 } // switch(dmisc1)
9094 811682 }
9095
9096 986571 hxofs=(misc>=2)?0:1000;
9097 986571 return enemy::animate(index);
9098 1018478 }
9099
9100 80892 bool eLeever::canplace(int32_t d2)
9101 {
9102 80892 int32_t nx=HeroX();
9103 80892 int32_t ny=HeroY();
9104
9105
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny=TRUNCATE_TILE(ny);
9106 52400 else nx=TRUNCATE_TILE(nx);
9107
9108
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9109 {
9110 case up:
9111
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9112 14174 break;
9113
9114 case down:
9115
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9116
9117
4/4
✓ Branch 0 taken 10087 times.
✓ Branch 1 taken 4231 times.
✓ Branch 2 taken 10076 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9118
9119 14318 break;
9120
9121 case left:
9122
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9123 26181 break;
9124
9125 case right:
9126
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9127
9128
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9129
9130 26219 break;
9131 }
9132
9133
4/4
✓ Branch 0 taken 20429 times.
✓ Branch 1 taken 60463 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11428 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9134 69464 return false;
9135
9136
2/2
✓ Branch 0 taken 865 times.
✓ Branch 1 taken 10563 times.
11428 if(d2>=left)
9137
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9138 9317 return false;
9139
9140 2111 x=nx;
9141 2111 y=ny;
9142 2111 dir=d2^1;
9143 2111 return true;
9144 80892 }
9145
9146 1024382 void eLeever::draw(BITMAP *dest)
9147 {
9148 // cs=d->cset;
9149 1024382 cs=dcset;
9150 1024382 update_enemy_frame();
9151
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9152 {
9153
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9154 {
9155 case -1:
9156 case 0:
9157 386939 return;
9158 }
9159 637088 }
9160
9161 637443 enemy::draw(dest);
9162 1024382 }
9163
9164 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9165 998 {
9166 998 hashero=false;
9167 //nets+1000;
9168
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9169 998 }
9170
9171 504762 bool eWallM::animate(int32_t index)
9172 {
9173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9174
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9175 {
9176 return enemy::animate(index);
9177 }
9178
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9179 9856 return Dead(index);
9180
9181
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9182 {
9183 30976 removearmos(x,y,ffcactivated);
9184 30976 }
9185
9186 494906 hxofs=1000;
9187
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9188 {
9189
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9190 {
9191 211789 int32_t wall=hero_on_wall();
9192 211789 int32_t wallm_cnt=0;
9193
9194
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9195
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->family==eeWALLM)
9196 {
9197 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9198
9199
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9200 {
9201 13366 ++wallm_cnt;
9202 13366 }
9203 1013091 }
9204
9205
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9206 {
9207 841 --wall;
9208 841 misc=1; //emerging from the wall?
9209 841 clk2=0;
9210 841 clk3=wall^1;
9211 841 wallm_load_clk=frame;
9212
9213
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9214 {
9215
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9216 91 dir=right;
9217 else
9218 423 dir=left;
9219 514 }
9220 else
9221 {
9222
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9223 66 dir=down;
9224 else
9225 261 dir=up;
9226 }
9227
9228
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9229 {
9230 case up:
9231 231 y=0;
9232 231 break;
9233
9234 case down:
9235 283 y=160;
9236 283 break;
9237
9238 case left:
9239 223 x=0;
9240 223 break;
9241
9242 case right:
9243 104 x=240;
9244 104 break;
9245 }
9246
9247
9248
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9249 {
9250 case up:
9251 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9252 261 flip=wall&1;
9253 261 break;
9254
9255 case down:
9256 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9257 66 flip=((wall&1)^1)+2;
9258 66 break;
9259
9260 case left:
9261 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9262 423 flip=(wall==up?2:0)+1;
9263 423 break;
9264
9265 case right:
9266 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9267 91 flip=(wall==up?2:0);
9268 91 break;
9269 }
9270
9271 841 }
9272 211789 }
9273 377174 }
9274 else
9275 117732 wallm_crawl();
9276
9277 494906 return enemy::animate(index);
9278 504762 }
9279
9280 117732 void eWallM::wallm_crawl()
9281 {
9282 117732 bool w=watch;
9283 117732 hxofs=0;
9284
9285
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9286 {
9287 810 return;
9288 }
9289
9290 // if(dying || watch || (!hashero && stunclk))
9291
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9292 {
9293 14546 return;
9294 }
9295
9296 102376 watch=false;
9297 102376 ++clk2;
9298 // Misc1: slightly different movement
9299 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9300
9301 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9303
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9304 {
9305 4491 --clk2;
9306 4491 }
9307
9308
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9309 {
9310 case 1:
9311 case 2:
9312 52852 zc_swap(dir,clk3);
9313 52852 move(step);
9314 52852 zc_swap(dir,clk3);
9315 52852 break;
9316
9317 case 3:
9318 case 4:
9319 case 5:
9320
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9321 {
9322 4491 watch=w;
9323 4491 return;
9324 }
9325
9326 34905 move(step);
9327 34905 break;
9328
9329 case 6:
9330 case 7:
9331 9984 zc_swap(dir,clk3);
9332 9984 dir^=1;
9333 9984 move(step);
9334 9984 dir^=1;
9335 9984 zc_swap(dir,clk3);
9336 9984 break;
9337
9338 default:
9339 144 misc=0;
9340 144 break;
9341 }
9342
9343 97885 watch=w;
9344 117732 }
9345
9346 9 void eWallM::grabhero()
9347 {
9348 9 hashero=true;
9349 9 superman=1;
9350 9 }
9351
9352 507147 void eWallM::draw(BITMAP *dest)
9353 {
9354 507147 dummy_bool[1]=hashero;
9355 507147 update_enemy_frame();
9356
9357
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9358 {
9359 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9360 129181 }
9361
9362 // enemy::draw(dest);
9363 // tile = clk&8 ? 128:129;
9364 507147 }
9365
9366 bool eWallM::isSubmerged() const
9367 {
9368 return ( !misc );
9369 }
9370
9371 1640 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9372 1640 {
9373
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 ox=x; //original x
9374
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 oy=y; //original y
9375
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 166 times.
1640 if(get_qr(qr_TRAPPOSFIX))
9376 {
9377
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
166 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9378 166 }
9379
9380 1640 mainguy=false;
9381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
1640 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9382 //nets+420;
9383 1640 dummy_int[1]=0;
9384
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1640 if (SIZEflags != 0) init_size_flags();;
9385 1640 }
9386
9387 1042165 bool eTrap::animate(int32_t index)
9388 {
9389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1042165 times.
1042165 if(switch_hooked) return enemy::animate(index);
9390
2/4
✓ Branch 0 taken 1042165 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1042165 times.
1042165 if(fallclk||drownclk) return enemy::animate(index);
9391
2/2
✓ Branch 0 taken 1020511 times.
✓ Branch 1 taken 21654 times.
1042165 if(clk<0)
9392 21654 return enemy::animate(index);
9393
9394
2/2
✓ Branch 0 taken 955962 times.
✓ Branch 1 taken 64549 times.
1020511 if(clk==0)
9395 {
9396 64549 removearmos(x,y,ffcactivated);
9397 64549 }
9398
9399
2/2
✓ Branch 0 taken 319209 times.
✓ Branch 1 taken 701302 times.
1020511 if(misc==0) // waiting
9400 {
9401 701302 ox = x;
9402 701302 oy = y;
9403 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9404 701302 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9405
9406
4/4
✓ Branch 0 taken 241777 times.
✓ Branch 1 taken 459525 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 108261 times.
701302 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9407 {
9408 108261 dir=down;
9409 108261 }
9410
4/4
✓ Branch 0 taken 393308 times.
✓ Branch 1 taken 199733 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 259792 times.
593041 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9411 {
9412 259792 dir=right;
9413 259792 }
9414
4/4
✓ Branch 0 taken 212039 times.
✓ Branch 1 taken 121210 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 78523 times.
333249 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9415 {
9416 78523 dir=up;
9417 78523 }
9418 else
9419 {
9420 254726 dir=left;
9421 }
9422
9423 701302 int32_t d2=lined_up(15,true);
9424
9425
4/4
✓ Branch 0 taken 268741 times.
✓ Branch 1 taken 432561 times.
✓ Branch 2 taken 1107234 times.
✓ Branch 3 taken 405932 times.
1095295 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9426
2/2
✓ Branch 0 taken 232564 times.
✓ Branch 1 taken 184572 times.
405932 ((d2>down) && (dmisc1==2)) ||
9427
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 75959 times.
184572 ((d2>right) && (!dmisc1)) ||
9428
2/2
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 130965 times.
263028 ((d2<l_up) && (dmisc1==4)) ||
9429
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 263028 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
130965 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9430
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 130965 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
263028 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9431 {
9432 2521777 d2=-1;
9433 2521777 }
9434
9435
4/4
✓ Branch 0 taken 20708 times.
✓ Branch 1 taken 417566 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2115 times.
438274 if(d2!=-1 && trapmove(d2))
9436 {
9437 2115 dir=d2;
9438 2115 misc=1;
9439 2115 clk2=(dir==down)?3:0;
9440 2115 }
9441 438274 }
9442
9443
2/2
✓ Branch 0 taken 667948 times.
✓ Branch 1 taken 89535 times.
757483 if(misc==1) // charging
9444 {
9445 89535 clk2=(clk2+1)&3;
9446 89535 step=(clk2==3)?1:2;
9447
9448
4/4
✓ Branch 0 taken 88731 times.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87626 times.
89535 if(!trapmove(dir) || clip())
9449 {
9450 1909 misc=2;
9451
9452
1/2
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
1909 if(dir<l_up)
9453 {
9454 1909 dir=dir^1;
9455 1909 }
9456 else
9457 {
9458 dir=dir^3;
9459 }
9460 1909 }
9461 else
9462 {
9463 87626 sprite::move(step);
9464 }
9465 89535 }
9466
9467
2/2
✓ Branch 0 taken 523785 times.
✓ Branch 1 taken 233698 times.
757483 if(misc==2) // retreating
9468 {
9469 233698 step=(++clk2&1)?1:0;
9470
9471
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80947 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84611 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
233698 switch(dir)
9472 {
9473 case up:
9474
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9475 38739 else sprite::move(step);
9476
9477 38739 break;
9478
9479 case left:
9480
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 80555 times.
80947 if(int32_t(x)<=ox) goto trap_rest;
9481 80555 else sprite::move(step);
9482
9483 80555 break;
9484
9485 case down:
9486
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9487 28905 else sprite::move(step);
9488
9489 28905 break;
9490
9491 case right:
9492
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 84176 times.
84611 if(int32_t(x)>=ox) goto trap_rest;
9493 84176 else sprite::move(step);
9494
9495 84176 break;
9496
9497 case l_up:
9498 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9499 else sprite::move(step);
9500
9501 break;
9502
9503 case r_up:
9504 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9505 else sprite::move(step);
9506
9507 break;
9508
9509 case l_down:
9510 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9511 else sprite::move(step);
9512
9513 break;
9514
9515 case r_down:
9516 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9517 else sprite::move(step);
9518
9519 break;
9520 trap_rest:
9521 {
9522 1323 x=ox;
9523 1323 y=oy;
9524 1323 misc=0;
9525 }
9526 1323 }
9527 233698 }
9528
9529 757483 return enemy::animate(index);
9530 779137 }
9531
9532 110243 bool eTrap::trapmove(int32_t ndir)
9533 {
9534
2/2
✓ Branch 0 taken 80479 times.
✓ Branch 1 taken 29764 times.
110243 if(get_qr(qr_MEANTRAPS))
9535 {
9536 80479 mapscr* scr = get_scr(screen_spawned);
9537
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 79139 times.
80479 if(scr->flags2&fFLOATTRAPS)
9538 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9539
9540 79139 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9541 }
9542
9543
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9544 4730 return false;
9545
9546
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9547 return false;
9548
9549
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9550 return false;
9551
9552
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9553 return false;
9554
9555
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9556 4722 return false;
9557
9558
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9559 713 return false;
9560
9561
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9562 return false;
9563
9564
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9565 return false;
9566
9567
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9568 return false;
9569
9570
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9571 return false;
9572
9573 19599 return true;
9574 110243 }
9575
9576 88731 bool eTrap::clip()
9577 {
9578
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45709 times.
88731 if(get_qr(qr_MEANPLACEDTRAPS))
9579 {
9580
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 16039 times.
✓ Branch 4 taken 15222 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45709 switch(dir)
9581 {
9582 case up:
9583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9584
9585 5792 break;
9586
9587 case down:
9588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=world_h-16) return true;
9589
9590 8656 break;
9591
9592 case left:
9593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16039 times.
16039 if(x<=0) return true;
9594
9595 16039 break;
9596
9597 case right:
9598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15222 times.
15222 if(x>=world_w-16) return true;
9599
9600 15222 break;
9601
9602 case l_up:
9603 if(y<=0||x<=0) return true;
9604
9605 break;
9606
9607 case l_down:
9608 if(y>=world_h-16||x<=0) return true;
9609
9610 break;
9611
9612 case r_up:
9613 if(y<=0||x>=world_w-16) return true;
9614
9615 break;
9616
9617 case r_down:
9618 if(y>=world_h-16||x>=world_w-16) return true;
9619
9620 break;
9621 }
9622
9623 45709 return false;
9624 }
9625 else
9626 {
9627
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9628 {
9629 case up:
9630
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9631
9632 4695 break;
9633
9634 case down:
9635
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9636
9637 5253 break;
9638
9639 case left:
9640
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9641
9642 16376 break;
9643
9644 case right:
9645
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9646
9647 15593 break;
9648
9649 case l_up:
9650 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9651
9652 break;
9653
9654 case l_down:
9655 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9656
9657 break;
9658
9659 case r_up:
9660 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9661
9662 break;
9663
9664 case r_down:
9665 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9666
9667 break;
9668 }
9669
9670 41917 return false;
9671 }
9672 88731 }
9673
9674 1061079 void eTrap::draw(BITMAP *dest)
9675 {
9676 1061079 update_enemy_frame();
9677 1061079 enemy::draw(dest);
9678 1061079 }
9679
9680 5705 int32_t eTrap::takehit(weapon*,weapon*)
9681 {
9682 5705 return 0;
9683 }
9684
9685 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9686 832 {
9687 832 lasthit=-1;
9688 832 lasthitclk=0;
9689 832 mainguy=false;
9690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9691
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9692
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9693 {
9694
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9695 399 }
9696 else
9697 {
9698
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9699 }
9700
9701
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9702 {
9703
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9704 72 }
9705
9706 //nets+((id==eTRAP_LR)?540:520);
9707 832 dummy_int[1]=0;
9708
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9709 832 }
9710
9711 346559 bool eTrap2::animate(int32_t index)
9712 {
9713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9714
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9715
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9716 11026 return enemy::animate(index);
9717
9718
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9719 {
9720 21385 removearmos(x,y,ffcactivated);
9721 21385 }
9722
9723
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9724 {
9725
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9726 {
9727 11074 --lasthitclk;
9728 11074 }
9729 else
9730 {
9731 113252 lasthit=-1;
9732 }
9733
9734 124326 bool hitenemy=false;
9735
9736
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9737 {
9738
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9739 {
9740
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9741 {
9742 3669 lasthit=j;
9743 3669 lasthitclk=10;
9744 3669 hitenemy=true;
9745 3669 guys.spr(j)->lasthit=index;
9746 3669 guys.spr(j)->lasthitclk=10;
9747 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9748 3669 }
9749 730351 }
9750 864860 }
9751
9752
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9753 {
9754
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9755 {
9756 3155 lasthit=-1;
9757 3155 lasthitclk=0;
9758 3155 }
9759
9760
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9761 362 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9762
9763 5986 dir=dir^1;
9764 5986 }
9765
9766 124326 sprite::move(step);
9767 124326 }
9768 else
9769 {
9770
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9771 {
9772
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9773 1521 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9774
9775 6919 dir=dir^1;
9776 6919 }
9777
9778 211207 sprite::move(step);
9779 }
9780
9781 335533 return enemy::animate(index);
9782 346559 }
9783
9784 341519 bool eTrap2::trapmove(int32_t ndir)
9785 {
9786 341519 mapscr* scr = get_scr(screen_spawned);
9787
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(scr->flags2&fFLOATTRAPS)
9788 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9789
9790 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9791 341519 }
9792
9793 328290 bool eTrap2::clip()
9794 {
9795
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9796 {
9797 case up:
9798
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9799
9800 88320 break;
9801
9802 case down:
9803
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=world_h-16) return true;
9804
9805 89029 break;
9806
9807 case left:
9808
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9809
9810 75153 break;
9811
9812 case right:
9813
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=world_w-16) return true;
9814
9815 75788 break;
9816 }
9817
9818 328290 return false;
9819 328290 }
9820
9821 350933 void eTrap2::draw(BITMAP *dest)
9822 {
9823 350933 update_enemy_frame();
9824 350933 enemy::draw(dest);
9825 350933 }
9826
9827 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9828 {
9829 3169 return 0;
9830 }
9831
9832 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9833 354 {
9834 //do not show "enemy appering" anim -DD
9835 354 clk=0;
9836 354 mainguy=false;
9837 354 clk2=-14;
9838 //Enemy Editor Size Tab
9839
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9840 //nets+1640;
9841 354 }
9842
9843 354 void eRock::init_size_flags()
9844 {
9845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9846 354 else hxofs = -2;
9847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9848 354 else hyofs = -2;
9849
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9850 354 else hit_width = 20;
9851
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9852 354 else hit_height = 20;
9853
9854
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9855
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9856
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9857
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9858
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9859 {
9860 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9861 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9862 }
9863
9864
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9865 354 }
9866
9867 121997 bool eRock::animate(int32_t index)
9868 {
9869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9870
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9872 return Dead(index);
9873
9874
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9875 {
9876 8376 removearmos(x,y,ffcactivated);
9877 8376 }
9878
9879
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9880 {
9881 697 x=zc_oldrand()&0xF0;
9882 697 y=0;
9883 697 clk3=0;
9884 697 clk2=zc_oldrand()&15;
9885 697 }
9886
9887
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9888 {
9889
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9890 {
9891 3430 dir=zc_oldrand()&1;
9892
9893
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9894
9895
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9896 3430 }
9897
9898
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9899 {
9900 95993 x += dir ? 1 : -1; //right, left
9901 95993 dummy_int[1]=dir;
9902
9903
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9904 {
9905 6852 y-=2; //up
9906 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9907 6852 }
9908
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9909 {
9910 10208 y--; //up
9911 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9912 10208 }
9913
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9914 {
9915 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9916 10135 }
9917
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9918 {
9919 10058 y++; //down
9920 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9921 10058 }
9922 else
9923 {
9924 58740 y+=2; //down
9925 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9926 }
9927
9928 95993 ++clk3;
9929 95993 }
9930
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<world_h)
9931 2761 clk3=0; // next bounce
9932 else
9933 423 clk2 = -(zc_oldrand()&63); // back to top
9934 99177 }
9935
9936 121997 return enemy::animate(index);
9937 121997 }
9938
9939 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9940 {
9941
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9942 {
9943 44250 int32_t tempy=yofs;
9944 44250 flip = 0;
9945 44250 int32_t fdiv = frate/4;
9946
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9947
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9948 44250 efrate:((clk>=(frate>>1))?1:0);
9949 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9950
9951 44250 yofs+=8;
9952
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9954 44250 sprite::drawshadow(dest, translucent);
9955 44250 yofs=tempy;
9956 44250 }
9957 51441 }
9958
9959 122078 void eRock::draw(BITMAP *dest)
9960 {
9961
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9962 {
9963 105043 int32_t tempdir=dir;
9964 105043 dir=dummy_int[2];
9965 105043 update_enemy_frame();
9966 105043 enemy::draw(dest);
9967 105043 dir=tempdir;
9968 105043 }
9969 122078 }
9970
9971 1014 int32_t eRock::takehit(weapon*,weapon*)
9972 {
9973 1014 return 0;
9974 }
9975
9976 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9977 30 {
9978 30 clk=0;
9979 30 mainguy=false;
9980 30 clk2=-14;
9981
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9982 //nets+1680;
9983 30 }
9984
9985 4440 bool eBoulder::animate(int32_t index)
9986 {
9987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9988
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9990 return Dead(index);
9991
9992
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9993 {
9994 290 removearmos(x,y,ffcactivated);
9995 290 }
9996
9997 zfix *vert;
9998
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9999
10000
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
10001 {
10002 32 x=zc_oldrand()&0xF0;
10003 32 y=-32;
10004 32 clk3=0;
10005 32 clk2=zc_oldrand()&15;
10006 32 }
10007
10008
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10009 {
10010
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10011 {
10012 131 dir=zc_oldrand()&1;
10013
10014
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10015
10016
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10017 131 }
10018
10019
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10020 {
10021 3487 x += dir ? 1 : -1; //right, left
10022 3487 dummy_int[1]=dir;
10023
10024
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10025 {
10026 261 y-=2; //up
10027 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10028 261 }
10029
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10030 {
10031 382 y--; //up
10032 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10033 382 }
10034
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10035 {
10036 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10037 376 }
10038
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10039 {
10040 367 y++; //down
10041 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10042 367 }
10043 else
10044 {
10045 2101 y+=2; //down
10046 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10047 }
10048
10049 3487 ++clk3;
10050 3487 }
10051
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10052 101 clk3=0; // next bounce
10053 else
10054 10 clk2 = -(zc_oldrand()&63); // back to top
10055 3598 }
10056
10057 4440 return enemy::animate(index);
10058 4440 }
10059
10060 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10061 {
10062
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10063 {
10064 3868 int32_t tempy=yofs;
10065 3868 flip = 0;
10066 3868 int32_t f2=((clk<<2)/frate)<<1;
10067 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10068
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10069
10070 3868 yofs+=8;
10071 3868 xofs-=8;
10072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10073 3868 sprite::drawshadow(dest, translucent);
10074 3868 xofs+=16;
10075 3868 ++shadowtile;
10076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10077 3868 sprite::drawshadow(dest, translucent);
10078 3868 yofs+=16;
10079 3868 shadowtile+=20;
10080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10081 3868 sprite::drawshadow(dest, translucent);
10082 3868 xofs-=16;
10083 3868 --shadowtile;
10084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10085 3868 sprite::drawshadow(dest, translucent);
10086 3868 xofs+=8;
10087 3868 yofs=tempy;
10088 3868 }
10089 4440 }
10090
10091 4440 void eBoulder::draw(BITMAP *dest)
10092 {
10093
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10094 {
10095 3868 int32_t tempdir=dir;
10096 3868 dir=dummy_int[2];
10097 3868 update_enemy_frame();
10098 3868 dir=tempdir;
10099 3868 xofs-=8;
10100 3868 yofs-=8;
10101 3868 drawblock(dest,15);
10102 3868 xofs+=8;
10103 3868 yofs+=8;
10104 // enemy::draw(dest);
10105 3868 }
10106 4440 }
10107
10108 30 void eBoulder::init_size_flags()
10109 {
10110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10111 30 else hxofs = -10;
10112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10113 30 else hyofs = -10;
10114
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10115 30 else hit_width = 36;
10116
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10117 30 else hit_height = 36;
10118
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10119 30 else hzsz = 16; //can't be jumped
10120
10121
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10122
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10123
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10124
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10125
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10126 {
10127 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10128 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10129 }
10130
10131
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10132 30 }
10133
10134 int32_t eBoulder::takehit(weapon*,weapon*)
10135 {
10136 return 0;
10137 }
10138
10139 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10140
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10141 4429 {
10142 /* fixing
10143 hp=1;
10144 */
10145 4429 mainguy=false;
10146
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10147 4429 hclk=clk; // the "no fire" range
10148 4429 clk=0;
10149 4429 clk3=96;
10150 4429 timer=0;
10151
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10152 {
10153 4415 superman=1;
10154 4415 hxofs=1000;
10155 4415 }
10156
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10157 4429 }
10158
10159 2504746 bool eProjectile::animate(int32_t index)
10160 {
10161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10162
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10163
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10164 {
10165 12326 removearmos(x,y,ffcactivated);
10166 12326 }
10167
10168 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10169 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10170
10171
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10172 {
10173 403631 dir=down;
10174 403631 }
10175
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10176 {
10177 916920 dir=right;
10178 916920 }
10179
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10180 {
10181 358900 dir=up;
10182 358900 }
10183 else
10184 {
10185 825295 dir=left;
10186 }
10187
10188
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10189 {
10190
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10191 {
10192
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10193 {
10194 563 unsigned r=zc_oldrand();
10195
10196
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10197 {
10198 6 timer=zc_oldrand()%50+50;
10199 6 }
10200 563 }
10201
10202
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10203 {
10204
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10205 {
10206 119 FireBreath(false);
10207 119 }
10208
10209
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10210 {
10211 6 clk3=0;
10212 6 }
10213 489 }
10214 1046 }
10215
10216 else // Not breath type
10217 {
10218 1197433 unsigned r=zc_oldrand();
10219
10220
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10221 {
10222 17542 FireWeapon();
10223
10224
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10225
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10226 {
10227
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10228 {
10229 909 x-=4;
10230 909 FireWeapon();
10231 909 x+=4;
10232 909 }
10233 14854 }
10234
10235 17542 clk3=0;
10236 17542 }
10237 }
10238 1198479 }
10239
10240 2504746 return enemy::animate(index);
10241 2504746 }
10242
10243 2520335 void eProjectile::draw(BITMAP *dest)
10244 {
10245 2520335 update_enemy_frame();
10246 2520335 enemy::draw(dest);
10247 2520335 }
10248
10249 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10250 533 {
10251 533 hxofs=1000;
10252 533 }
10253
10254 249811 void eTrigger::draw(BITMAP *dest)
10255 {
10256 249811 update_enemy_frame();
10257 249811 enemy::draw(dest);
10258 249811 }
10259
10260 void eTrigger::death_sfx()
10261 {
10262 //silent death
10263 }
10264
10265 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10266 5 {
10267 5 o_tile+=wpnsbuf[iwNPCs].tile;
10268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10269 5 SIZEflags = d->SIZEflags;
10270
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10271 5 }
10272
10273 75 bool eNPC::animate(int32_t index)
10274 {
10275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10276
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10277 70 return Dead(index);
10278
10279
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10280 {
10281 removearmos(x,y,ffcactivated);
10282 }
10283
10284
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10285 {
10286 case 0:
10287 {
10288 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10289 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10290
10291
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10292 {
10293 dir=down;
10294 }
10295
10296
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10297 {
10298 5 dir=right;
10299 5 }
10300 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10301 {
10302 dir=up;
10303 }
10304 else
10305 {
10306 dir=left;
10307 }
10308 }
10309 5 break;
10310
10311 case 1:
10312 halting_walk(rate, homing, 0, hrate, 48);
10313
10314 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10315 {
10316 newdir(rate, homing, 0);
10317 clk2=48;
10318 ++misc;
10319 }
10320
10321 if(clk2==0)
10322 misc=0;
10323
10324 break;
10325 }
10326
10327 5 return enemy::animate(index);
10328 75 }
10329
10330 75 void eNPC::draw(BITMAP *dest)
10331 {
10332 75 update_enemy_frame();
10333 75 enemy::draw(dest);
10334 75 }
10335
10336 int32_t eNPC::takehit(weapon*,weapon*)
10337 {
10338 return 0;
10339 }
10340
10341 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10342 94 {
10343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10344 {
10345 94 o_tile=clk;
10346 94 cs=id>>12;
10347 94 }
10348
10349 94 id=id&0xFFF;
10350 94 clk=0;
10351
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10352 94 mainguy=false;
10353 94 SIZEflags = d->SIZEflags;
10354
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10355 94 }
10356
10357 81 void eSpinTile::facehero()
10358 {
10359
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10360 {
10361
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10362 1 dir = up;
10363 else
10364 dir = down;
10365 1 }
10366 else
10367 {
10368 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10369 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10370
10371
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10372 {
10373 12 dir=l_down;
10374 12 }
10375
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10376 {
10377 1 dir=down;
10378 1 }
10379
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10380 {
10381 12 dir=r_down;
10382 12 }
10383
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10384 {
10385 6 dir=right;
10386 6 }
10387
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10388 {
10389 17 dir=r_up;
10390 17 }
10391
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10392 {
10393 8 dir=up;
10394 8 }
10395
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10396 {
10397 6 dir=l_up;
10398 6 }
10399 else
10400 {
10401 18 dir=left;
10402 }
10403 }
10404 81 }
10405
10406
10407 15539 bool eSpinTile::animate(int32_t index)
10408 {
10409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10410
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10411
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10412 {
10413 1152 return Dead(index);
10414 }
10415
10416
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10417 {
10418 1241 removearmos(x,y,ffcactivated);
10419 1241 }
10420
10421 14387 ++misc;
10422
10423
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10424 {
10425 81 facehero();
10426 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10427 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10428 81 angular=true;
10429 81 angle=ddir;
10430 81 step=zslongToFix(dstep*100);
10431 81 }
10432
10433
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10434 52 kickbucket();
10435
10436 14387 sprite::move(step);
10437 14387 return enemy::animate(index);
10438 15539 }
10439
10440 15457 void eSpinTile::draw(BITMAP *dest)
10441 {
10442 15457 update_enemy_frame();
10443 15457 y-=(misc>>4);
10444 15457 yofs+=2;
10445 15457 enemy::draw(dest);
10446 15457 yofs-=2;
10447 15457 y+=(misc>>4);
10448 15457 }
10449
10450 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10451 {
10452 15457 flip = 0;
10453 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10454 15457 yofs+=4;
10455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10456 15457 enemy::drawshadow(dest, translucent);
10457 15457 yofs-=4;
10458 15457 }
10459
10460 2797 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10461 2797 {
10462 //these are here to bypass compiler warnings about unused arguments
10463 2797 Clk=Clk;
10464 2797 mainguy=false;
10465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2797 times.
2797 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10466
1/4
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2797 if (SIZEflags != 0) init_size_flags();;
10467 2797 }
10468
10469 628398 void eZora::facehero()
10470 {
10471
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 617613 times.
628398 if(Hero.x-x==0)
10472 {
10473 10785 dir=(Hero.y+8<y)?up:down;
10474 10785 }
10475 else
10476 {
10477 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10478 617613 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10479
10480
4/4
✓ Branch 0 taken 125430 times.
✓ Branch 1 taken 492183 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 78554 times.
617613 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10481 {
10482 78554 dir=l_down;
10483 78554 }
10484
4/4
✓ Branch 0 taken 91951 times.
✓ Branch 1 taken 447108 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 45075 times.
539059 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10485 {
10486 45075 dir=down;
10487 45075 }
10488
4/4
✓ Branch 0 taken 121090 times.
✓ Branch 1 taken 372894 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 74214 times.
493984 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10489 {
10490 74214 dir=r_down;
10491 74214 }
10492
4/4
✓ Branch 0 taken 162238 times.
✓ Branch 1 taken 257532 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 115362 times.
419770 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10493 {
10494 115362 dir=right;
10495 115362 }
10496
4/4
✓ Branch 0 taken 127279 times.
✓ Branch 1 taken 177129 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 80403 times.
304408 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10497 {
10498 80403 dir=r_up;
10499 80403 }
10500
4/4
✓ Branch 0 taken 88819 times.
✓ Branch 1 taken 135186 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 41943 times.
224005 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10501 {
10502 41943 dir=up;
10503 41943 }
10504
4/4
✓ Branch 0 taken 121548 times.
✓ Branch 1 taken 60514 times.
✓ Branch 2 taken 74672 times.
✓ Branch 3 taken 46876 times.
182062 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10505 {
10506 74672 dir=l_up;
10507 74672 }
10508 else
10509 {
10510 107390 dir=left;
10511 }
10512 }
10513 628398 }
10514
10515 857137 bool eZora::animate(int32_t index)
10516 {
10517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 857137 times.
857137 if(switch_hooked) return enemy::animate(index);
10518
2/2
✓ Branch 0 taken 2854 times.
✓ Branch 1 taken 854283 times.
857137 if(dying)
10519 2854 return Dead(index);
10520
10521
2/2
✓ Branch 0 taken 848537 times.
✓ Branch 1 taken 5746 times.
854283 if(clk==0)
10522 {
10523 5746 removearmos(x,y,ffcactivated);
10524 5746 }
10525
10526
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 854248 times.
854283 if(watch)
10527 {
10528 35 clock_zoras.push_back({screen_spawned, id});
10529 35 return true;
10530 }
10531
10532
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 628398 times.
854248 if(get_qr(qr_NEWENEMYTILES))
10533 {
10534 628398 facehero();
10535 628398 }
10536
10537
6/6
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 4993 times.
✓ Branch 2 taken 4190 times.
✓ Branch 3 taken 830374 times.
✓ Branch 4 taken 6482 times.
✓ Branch 5 taken 2977 times.
854248 switch(clk)
10538 {
10539 case 0: // reposition him
10540 {
10541 6482 int32_t t=0;
10542 6482 int32_t pos2=zc_oldrand()%160 + 16;
10543 6482 bool placed=false;
10544
10545
4/4
✓ Branch 0 taken 6417 times.
✓ Branch 1 taken 38529 times.
✓ Branch 2 taken 26366 times.
✓ Branch 3 taken 5746 times.
44946 while(!placed && t<160)
10546 {
10547 26366 rpos_t rpos = POS_TO_RPOS(pos2, screen_spawned);
10548 90460 auto [sx, sy] = COMBOXY_REGION(rpos);
10549 26366 mapscr* s = get_scr(screen_spawned);
10550
10551 79098 int32_t watertype = iswaterex_z3(s->data[pos2], -1, sx, sy, false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10552
5/6
✓ Branch 0 taken 6604 times.
✓ Branch 1 taken 19762 times.
✓ Branch 2 taken 6604 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5681 times.
32447 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10553
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6572 times.
6604 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10554
3/4
✓ Branch 0 taken 6572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6081 times.
✓ Branch 3 taken 6049 times.
6604 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10555 {
10556 5681 x=sx;
10557 5681 y=sy;
10558
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5341 times.
5681 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10559 5681 hxofs=1000; // avoid hit detection
10560 5681 stunclk=0;
10561 5681 placed=true;
10562 5681 }
10563
10564 38464 pos2+=19;
10565
10566
2/2
✓ Branch 0 taken 33901 times.
✓ Branch 1 taken 4563 times.
38464 if(pos2>=176)
10567 4563 pos2-=160;
10568
10569 38464 ++t;
10570 }
10571
10572
3/4
✓ Branch 0 taken 5681 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5681 times.
5746 if(!placed || whistleclk>=88) // can't place him, he's gone
10573 65 return true;
10574
10575 }
10576 5681 break;
10577
10578 case 35:
10579
2/2
✓ Branch 0 taken 3871 times.
✓ Branch 1 taken 1361 times.
5232 if(!get_qr(qr_NEWENEMYTILES))
10580 {
10581 1361 dir=(Hero.y+8<y)?up:down;
10582 1361 }
10583
10584 5232 hxofs=0;
10585 5232 break;
10586
10587 case 35+19:
10588 4993 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10589 4993 sfx(wpnsfx(wpn),pan(int32_t(x)));
10590 4993 break;
10591
10592 case 35+66:
10593 4190 hxofs=1000;
10594 4190 break;
10595
10596 case 198:
10597 2977 clk=-1;
10598 2977 break;
10599 }
10600
10601 853447 return enemy::animate(index);
10602 856401 }
10603
10604 867086 void eZora::draw(BITMAP *dest)
10605 {
10606
2/2
✓ Branch 0 taken 20009 times.
✓ Branch 1 taken 847077 times.
867086 if (isSubmerged())
10607 20009 return;
10608
10609 847077 update_enemy_frame();
10610 847077 enemy::draw(dest);
10611 867086 }
10612
10613 867318 bool eZora::isSubmerged() const
10614 {
10615 867318 return clk < 3;
10616 }
10617
10618
3/6
✓ Branch 0 taken 50256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50256 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50256 times.
✗ Branch 5 not taken.
100512 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10619 50256 {
10620 50256 multishot= timer = fired = dashing = 0;
10621 50256 hashero = false;
10622 50256 dummy_bool[0]=false;
10623
4/8
✓ Branch 0 taken 50256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50256 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50256 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50256 times.
✗ Branch 7 not taken.
50256 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10624
5/6
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 49254 times.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 519 times.
✓ Branch 5 taken 483 times.
50256 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10625 {
10626
2/4
✓ Branch 0 taken 519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
519 step=zslongToFix(dmisc10*100);
10627
10628
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 501 times.
519 if(anim==aARMOS4) o_tile+=20;
10629 519 }
10630
10631
3/4
✓ Branch 0 taken 50256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✓ Branch 3 taken 49254 times.
50256 if(flags & guy_fade_flicker)
10632 {
10633 1002 clk=0;
10634 1002 superman = 1;
10635 1002 fading=fade_flicker;
10636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10637 1002 dir=down;
10638
10639
4/6
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 561 times.
1002 if(!canmove(down,(zfix)8,spw_none,false))
10640
3/6
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 441 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✗ Branch 5 not taken.
441 clk3=int32_t(13.0/step);
10641 1002 }
10642
3/4
✓ Branch 0 taken 49254 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49121 times.
✓ Branch 3 taken 133 times.
49254 else if(flags & guy_fade_instant)
10643 {
10644 133 clk=0;
10645 133 }
10646
10647
1/2
✓ Branch 0 taken 50256 times.
✗ Branch 1 not taken.
50256 shadowdistance = 0;
10648 50256 clk4 = clk5 = 0;
10649 //nets+2380;
10650
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50254 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50256 if (SIZEflags != 0) init_size_flags();;
10651 50256 }
10652
10653 15822880 bool eStalfos::animate(int32_t index)
10654 {
10655
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15822624 times.
15822880 if(switch_hooked) return enemy::animate(index);
10656
3/4
✓ Branch 0 taken 15822198 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15822198 times.
15822624 if(fallclk||drownclk)
10657 {
10658 426 return enemy::animate(index);
10659 }
10660
2/2
✓ Branch 0 taken 353006 times.
✓ Branch 1 taken 15469192 times.
15822198 if(dying)
10661 {
10662
2/2
✓ Branch 0 taken 352958 times.
✓ Branch 1 taken 48 times.
353006 if(hashero)
10663 {
10664 48 Hero.setEaten(0);
10665 48 hashero=false;
10666 48 }
10667
10668
10/14
✓ Branch 0 taken 36032 times.
✓ Branch 1 taken 316974 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32347 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
353006 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10669 {
10670 187 hp=-1000;
10671
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10672 187 Ewpns.add(ew);
10673 187 ew->fakez = fakez;
10674
10675
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10676 {
10677 187 ew->step=0;
10678 187 ew->id=wpn;
10679 187 ew->misc=50;
10680 187 ew->clk=48;
10681 187 }
10682
10683 187 fired=true;
10684 187 }
10685
6/6
✓ Branch 0 taken 156352 times.
✓ Branch 1 taken 196467 times.
✓ Branch 2 taken 130300 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130282 times.
✓ Branch 5 taken 18 times.
352819 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10686 {
10687
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10688 {
10689 1 int32_t wpn2 = wpn+dmisc3;
10690
10691
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10692 {
10693 wpn2=wpn;
10694 }
10695
10696 1 dummy_bool[0]=true;
10697 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10698 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10699 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10700 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10701 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10702 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10703 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10704 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10705 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10706 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10707 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10708 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10709 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10710 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10711 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10712 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10713 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10714 1 }
10715 18 }
10716
10717 353006 KillWeapon();
10718 353006 return Dead(index);
10719 }
10720 //vire split
10721 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10722 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10723
13/14
✓ Branch 0 taken 21142 times.
✓ Branch 1 taken 15448050 times.
✓ Branch 2 taken 21142 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20791 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14276145 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15469192 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10724 {
10725 1677 stop_bgsfx(index);
10726 1677 int32_t kids = guys.Count();
10727 1677 int32_t id2=dmisc3;
10728
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10729 {
10730
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(screen_spawned,x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10731 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10732 3307 }
10733
10734
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1677 if (itemguy && guys.Count()) // Hand down the carried item
10735 {
10736 1 int guycarryingitem = guys.Count()-1;
10737 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10738 1 itemguy = false;
10739 1 }
10740
10741
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10742 {
10743 17 Hero.setEaten(0);
10744 17 hashero=false;
10745 17 }
10746
10747
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10748 323 sfx(deadsfx,pan(int32_t(x)));
10749
10750 1677 return true;
10751 }
10752
10753
2/2
✓ Branch 0 taken 71160 times.
✓ Branch 1 taken 15396355 times.
15467515 if(fading)
10754 {
10755
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 69932 times.
71160 if(++clk4 > 60)
10756 {
10757 1228 clk4=0;
10758 1228 superman=0;
10759 1228 fading=0;
10760
10761
4/6
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 967 times.
1228 if(flags&guy_armos && z==0 && fakez == 0)
10762 {
10763 //if a custom size (not 16px by 16px)
10764
10765 //if a custom size (not 16px by 16px)
10766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 967 times.
967 if (ffcactivated)
10767 removearmosffc(*ffcactivated);
10768 else
10769 {
10770
4/8
✓ Branch 0 taken 967 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 967 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 967 times.
967 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10771 {
10772 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10773 for(int32_t dx = 0; dx < tysz; dx ++)
10774 {
10775 for(int32_t dy = 0; dy < tysz; dy++)
10776 {
10777 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10778 did_armos = false;
10779 }
10780 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10781 did_armos = false;
10782 }
10783 for(int32_t dy = 0; dy < tysz; dy ++)
10784 {
10785 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10786 did_armos = false;
10787 }
10788 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10789 }
10790 967 else removearmos(x,y);
10791 }
10792
10793 967 }
10794
10795 1228 clk2=0;
10796
10797 1228 newdir();
10798 1228 }
10799 69932 else return enemy::animate(index);
10800 1228 }
10801
6/8
✓ Branch 0 taken 148409 times.
✓ Branch 1 taken 15247946 times.
✓ Branch 2 taken 148409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148409 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 138854 times.
✓ Branch 7 taken 9555 times.
15396355 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10802 9555 removearmos(x,y,ffcactivated);
10803
10804
10805
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15390376 times.
15397583 if(hashero)
10806 {
10807 7207 Hero.setX(x);
10808 7207 Hero.setY(y);
10809 7207 ++clk2;
10810
10811
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10812 {
10813
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10814 {
10815 case e7tEATITEMS:
10816 {
10817
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10818 {
10819
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10820 22 game->set_item(i, false);
10821 5632 }
10822
10823 22 break;
10824 }
10825
10826 case e7tEATMAGIC:
10827 game->change_dmagic(-1*game->get_magicdrainrate());
10828 break;
10829
10830 case e7tEATRUPEES:
10831 game->change_drupy(-1);
10832 break;
10833 }
10834
10835 899 clk2=0;
10836 899 }
10837
10838
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10839 6661 --clk;
10840 7207 }
10841
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14341503 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15390376 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10842 {
10843 // Movement engine
10844
6/6
✓ Branch 0 taken 839440 times.
✓ Branch 1 taken 14118100 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14114639 times.
✓ Branch 5 taken 59 times.
14957540 if(clk>=0) switch(id>>12)
10845 {
10846 case 0: // Normal movement
10847
10848 /*
10849 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10850 {
10851 // Overloading clk4 (Tribble clock) here...
10852 step=17/100.0;
10853 if(clk4<32) misc=1;
10854 else if(clk4<48) misc=2;
10855 else if(clk4<300) { misc=3; step = dstep/100.0; }
10856 else if(clk4<316) misc=2;
10857 else if(clk4<412) misc=1;
10858 else if(clk4<540) { misc=0; step=0; }
10859 else clk4=0;
10860 if(clk4==48) clk=0;
10861 hxofs=(misc>=2)?0:1000;
10862 if (dmisc9==e9tLEEVER)
10863 variable_walk(rate, homing, 0);
10864 else
10865 variable_walk_8(rate, homing, 4, 0);
10866 break;
10867 }
10868 */
10869
4/4
✓ Branch 0 taken 13735605 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13318529 times.
14114639 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10870 {
10871 796110 vire_hop();
10872 796110 break;
10873 }
10874
2/2
✓ Branch 0 taken 984687 times.
✓ Branch 1 taken 12333842 times.
13318529 else if(dmisc9==e9tROPE) //Rope charge
10875 {
10876
9/10
✓ Branch 0 taken 967265 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138779 times.
✓ Branch 3 taken 828486 times.
✓ Branch 4 taken 126694 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125869 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125869 times.
984687 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10877 {
10878
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116793 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125869 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10879 {
10880
10881
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10882 {
10883 14 hp=-1000;
10884
10885
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10886 {
10887
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10888 14 Ewpns.add(ew);
10889 14 ew->fakez = fakez;
10890
10891
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10892 {
10893 14 ew->step=0;
10894 14 ew->id=wpn+dmisc3;
10895 14 ew->misc=50;
10896 14 ew->clk=48;
10897 14 }
10898
10899 14 fired=true;
10900 14 }
10901 else
10902 {
10903 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10904 Ewpns.add(ew);
10905 ew->fakez = fakez;
10906
10907 if(wpn==ewSBomb || wpn==ewBomb)
10908 {
10909 ew->step=0;
10910 ew->id=wpn;
10911 ew->misc=50;
10912 ew->clk=48;
10913 }
10914
10915 fired=true;
10916 }
10917 14 }
10918
10919 else
10920 {
10921 33 hp=-1000;
10922
10923 int32_t wpn2;
10924
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10925 33 wpn2=wpn;
10926 else
10927 wpn2=wpn;
10928
10929
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10930 33 Ewpns.add(ew);
10931 33 ew->fakez = fakez;
10932
10933
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10934 {
10935 33 ew->step=0;
10936 33 ew->id=wpn2;
10937 33 ew->misc=50;
10938 33 ew->clk=48;
10939 33 }
10940
10941 33 fired=true;
10942 }
10943 47 }
10944 125869 }
10945
10946 984687 charge_attack();
10947 984687 break;
10948 }
10949 /*
10950 * Boomerang-throwers have a halt count of 1
10951 * Zols have a halt count of (zc_oldrand()&7)<<4
10952 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10953 * Everything else has 48
10954 */
10955 else
10956 {
10957
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11765423 times.
12333842 if(wpn==ewBrang) // Goriya
10958 {
10959 568419 halting_walk(rate,homing,0,hrate, 1);
10960 568419 }
10961
4/4
✓ Branch 0 taken 11616047 times.
✓ Branch 1 taken 149376 times.
✓ Branch 2 taken 4551928 times.
✓ Branch 3 taken 7064119 times.
11765423 else if(dmisc9==e9tNORMAL && wpn==0)
10962 {
10963
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6346146 times.
7064119 if(dmisc2==e2tSPLITHIT) // Zol
10964 {
10965 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10966 717973 }
10967
4/4
✓ Branch 0 taken 1754155 times.
✓ Branch 1 taken 4591991 times.
✓ Branch 2 taken 1538264 times.
✓ Branch 3 taken 215891 times.
6346146 else if(frate<=8 && starting_hp==1) // Gel
10968 {
10969 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10970 215891 }
10971 else // Other
10972 {
10973 6130255 halting_walk(rate,homing,0,hrate, 48);
10974 }
10975 7064119 }
10976 else // Other
10977 {
10978 4701304 halting_walk(rate,homing,0,hrate, 48);
10979 }
10980 }
10981
10982 //if not in midair, and Hero's swinging sword is nearby, jump.
10983 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10984 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10985 {
10986 facehero(false);
10987 sclk=16+((dir^1)<<8);
10988 fall=-FEATHERJUMP;
10989 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
10990 }*/
10991 12333842 break;
10992
10993 // Following cases are for just after creation-by-splitting.
10994 case 1:
10995
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
10996 {
10997 821 dir=up;
10998 821 step=8;
10999 821 }
11000
11001
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
11002 {
11003 2504 move(step);
11004
11005
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
11006 512 dir=down;
11007 2504 }
11008
11009
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
11010 {
11011
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
11012 503 x+=16;
11013 790 }
11014
11015 3294 ++misc;
11016 3294 break;
11017
11018 case 2:
11019
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
11020 {
11021 15 dir=down;
11022 15 step=8;
11023 15 }
11024
11025
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
11026 {
11027 45 move(step);
11028 /*
11029 if(!canmove(dir,(zfix)0,0,false))
11030 dir=up;
11031 */
11032 45 }
11033
11034
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11035 {
11036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11037 14 x-=16;
11038 14 }
11039
11040 59 ++misc;
11041 59 break;
11042
11043 default:
11044
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11045 {
11046 28 dir=(zc_oldrand()%4);
11047 28 step=8;
11048 28 }
11049
11050
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11051 {
11052 83 move(step);
11053
11054
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11055 2 dir=dir^1;
11056 83 }
11057
11058
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11059 {
11060
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11061 8 x+=(dir==left ? -16 : 16);
11062 25 }
11063
11064 108 ++misc;
11065 108 break;
11066 14118100 }
11067
11068
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14932268 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14957540 if(id>>12 && misc>=4) //recently spawned by a split enemy
11069 {
11070 829 id&=0xFFF;
11071 829 step = zslongToFix(dstep*100);
11072
11073
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11074
11075
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>world_w-48) x=world_w-48;
11076
11077
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11078
11079
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>world_h-48) y=world_h-48;
11080
11081 829 misc=3;
11082 829 }
11083 14957540 }
11084 else
11085 {
11086 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11087
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11088 }
11089
11090 // Fire Zol
11091
8/8
✓ Branch 0 taken 6104645 times.
✓ Branch 1 taken 9292938 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5965364 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15397583 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11092 {
11093 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11094 1102 sfx(wpnsfx(wpn),pan(int32_t(x)));
11095
11096 1102 int32_t i=Ewpns.Count()-1;
11097 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11098
11099
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11100 {
11101 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11102 if ( ew->do_animation ) ew->tile+=ew->aframe;
11103 }
11104 1102 }
11105 // Goriya
11106
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14347608 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15396481 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11107 {
11108 6362 misc=index+100;
11109
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11110 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11111
11112
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11113 {
11114 257 int32_t ndir=dir;
11115
11116
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11117 {
11118 6 ndir=(Hero.y+8<y)?up:down;
11119 6 }
11120 else //turn to face Hero
11121 {
11122 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11123 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11124
11125
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11126 {
11127 13 ndir=down;
11128 13 }
11129
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11130 {
11131 68 ndir=right;
11132 68 }
11133
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11134 {
11135 48 ndir=up;
11136 48 }
11137 else
11138 {
11139 122 ndir=left;
11140 }
11141 }
11142
11143 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11144
11145
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11146 {
11147 223 dir=ndir;
11148 223 }
11149 257 }
11150 6362 }
11151
15/16
✓ Branch 0 taken 15331233 times.
✓ Branch 1 taken 58886 times.
✓ Branch 2 taken 221198 times.
✓ Branch 3 taken 15168921 times.
✓ Branch 4 taken 195080 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170188 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168804 times.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 153704 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 153704 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152760 times.
15390119 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11152
3/3
✓ Branch 0 taken 26122 times.
✓ Branch 1 taken 125732 times.
✓ Branch 2 taken 906 times.
152760 switch(dmisc1)
11153 {
11154 case e1tCONSTANT: //Deathnut
11155 {
11156 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11157
2/2
✓ Branch 0 taken 123149 times.
✓ Branch 1 taken 2583 times.
125732 if(clk5>64)
11158 {
11159 2583 clk5=0;
11160 2583 fired=false;
11161 2583 }
11162
11163 125732 clk5+=(zc_oldrand()&3);
11164
11165
4/4
✓ Branch 0 taken 76714 times.
✓ Branch 1 taken 49018 times.
✓ Branch 2 taken 25645 times.
✓ Branch 3 taken 51069 times.
125732 if((clk5>24)&&(clk5<52))
11166 {
11167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51069 times.
51069 if ( do_animation )tile+=20; //firing
11168
11169
4/4
✓ Branch 0 taken 27958 times.
✓ Branch 1 taken 23111 times.
✓ Branch 2 taken 25131 times.
✓ Branch 3 taken 2827 times.
51069 if(!fired&&(clk5>=38))
11170 {
11171
5/10
✓ Branch 0 taken 2827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2827 times.
✗ Branch 9 not taken.
2827 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11172 2827 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11173 2827 sfx(wpnsfx(wpn),pan(int32_t(x)));
11174 2827 fired=true;
11175 2827 }
11176 51069 }
11177
11178 125732 break;
11179 }
11180
11181 case e1tFIREOCTO: //Fire Octo
11182 906 timer=zc_oldrand()%50+50;
11183 906 break;
11184
11185 default:
11186 26122 FireWeapon();
11187 26122 break;
11188 152760 }
11189
11190 /* Fire again if:
11191 * - clk2 about to run out
11192 * - not already double-firing (dmisc1 is 1)
11193 * - not carrying Hero
11194 * - one in 0xF chance
11195 */
11196
8/10
✓ Branch 0 taken 524938 times.
✓ Branch 1 taken 14872645 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520936 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15397583 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11197 {
11198 #if 1
11199 251 newdir(rate, homing, grumble);
11200 #else
11201 dir^=2;
11202 #endif
11203 251 clk2=28;
11204 251 ++multishot;
11205 251 }
11206
11207
2/2
✓ Branch 0 taken 3492669 times.
✓ Branch 1 taken 11904914 times.
15397583 if(clk2==0)
11208 {
11209 11904914 multishot = 0;
11210 11904914 }
11211
11212
2/2
✓ Branch 0 taken 15333273 times.
✓ Branch 1 taken 64310 times.
15397583 if(timer) //Fire Octo
11213 {
11214 64310 clk2=15; //this keeps the octo in place until he's done firing
11215
11216
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11217 {
11218 15752 FireBreath(false);
11219 15752 }
11220
11221 64310 --timer;
11222 64310 }
11223
11224
2/2
✓ Branch 0 taken 15148190 times.
✓ Branch 1 taken 249393 times.
15397583 if(dmisc2==e2tTRIBBLE)
11225 249393 ++clk4;
11226
11227
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15393103 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15396890 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15397583 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11228 {
11229 693 int32_t kids = guys.Count();
11230 693 int32_t id2=dmisc3;
11231
11232
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11233 {
11234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(screen_spawned,x,y,id2,-24))
11235 {
11236
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11237 {
11238 int guycarryingitem = guys.Count()-1;
11239 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11240 itemguy = false;
11241 }
11242
11243 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11244 693 }
11245 693 }
11246
11247
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11248 {
11249 Hero.setEaten(0);
11250 hashero=false;
11251 }
11252
11253 693 stop_bgsfx(index);
11254 693 return true;
11255 }
11256
11257 15396890 return enemy::animate(index);
11258 15822880 }
11259
11260 16245173 void eStalfos::draw(BITMAP *dest)
11261 {
11262 16245173 update_enemy_frame();
11263
11264
7/8
✓ Branch 0 taken 16244747 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16244747 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16157796 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16245173 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11265 {
11266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11267 11115 }
11268
11269 16245173 enemy::draw(dest);
11270 16245173 }
11271
11272 7536221 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11273 {
11274 7536221 int32_t tempy=yofs;
11275
11276
4/4
✓ Branch 0 taken 7320803 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7224602 times.
✓ Branch 3 taken 311619 times.
7536221 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11277 {
11278 311619 flip = 0;
11279 311619 int32_t fdiv = frate/4;
11280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11281
11282
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11283 311619 efrate:((clk>=(frate>>1))?1:0);
11284 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11285
11286
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11287 {
11288 311619 shadowtile+=f2;
11289 311619 }
11290 else
11291 {
11292 shadowtile+=f2?1:0;
11293 }
11294
11295 311619 yofs+=shadowdistance;
11296 311619 yofs+=8;
11297 311619 }
11298
4/4
✓ Branch 0 taken 7320803 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7533186 times.
✓ Branch 3 taken 3035 times.
7536221 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11299 {
11300 3035 flip = 0;
11301 3035 int32_t fdiv = frate/4;
11302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11303
11304
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11305 3035 efrate:((clk>=(frate>>1))?1:0);
11306 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11307
11308
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11309 {
11310 3035 shadowtile+=f2;
11311 3035 }
11312 else
11313 {
11314 shadowtile+=f2?1:0;
11315 }
11316 3035 }
11317
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7530725 times.
7536221 if(!shadow_overpit(this))
11318 7530725 enemy::drawshadow(dest, translucent);
11319 7536221 yofs=tempy;
11320 7536221 }
11321
11322 157814 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11323 {
11324 157814 int32_t wpnId = w->id;
11325 157814 int32_t wpnDir = w->dir;
11326
11327
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156396 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 809 times.
157814 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11328
6/8
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265 times.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
609 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11329
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11330 {
11331 265 shield = false;
11332 265 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11333
11334
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 243 times.
265 if(get_qr(qr_BRKNSHLDTILES))
11335 243 o_tile=s_tile;
11336 265 }
11337
11338 157814 int32_t ret = enemy::takehit(w,realweap);
11339
11340
4/4
✓ Branch 0 taken 22327 times.
✓ Branch 1 taken 135487 times.
✓ Branch 2 taken 20576 times.
✓ Branch 3 taken 1751 times.
157814 if(sclk && dmisc2==e2tSPLITHIT)
11341 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11342
11343 157814 return ret;
11344 }
11345
11346 984687 void eStalfos::charge_attack()
11347 {
11348
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 977972 times.
984687 if(slide())
11349 6715 return;
11350
11351
10/12
✓ Branch 0 taken 977972 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 975568 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 946055 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 924502 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 918879 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 918879 times.
977972 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11352 59093 return;
11353
11354
2/2
✓ Branch 0 taken 37515 times.
✓ Branch 1 taken 881364 times.
918879 if(clk3<=0)
11355 {
11356 37515 fix_coords(true);
11357
11358
2/2
✓ Branch 0 taken 10043 times.
✓ Branch 1 taken 27472 times.
37515 if(!dashing)
11359 {
11360 27472 int32_t ldir = lined_up(7,false);
11361
11362
4/4
✓ Branch 0 taken 3107 times.
✓ Branch 1 taken 24365 times.
✓ Branch 2 taken 456 times.
✓ Branch 3 taken 2651 times.
27472 if(ldir!=-1 && canmove(ldir,false))
11363 {
11364 2651 dir=ldir;
11365 2651 dashing=true;
11366
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2651 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2651 if (dmisc10<=0 || replay_version_check(0,33) || get_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE))
11367 2651 step=zslongToFix(dstep*100)+1;
11368 else
11369 step=zslongToFix(dmisc10*100);
11370 2651 }
11371 24821 else newdir(4,0,0);
11372 27472 }
11373
11374
2/2
✓ Branch 0 taken 36061 times.
✓ Branch 1 taken 1454 times.
37515 if(!canmove(dir,false))
11375 {
11376 1454 step=zslongToFix(dstep*100);
11377 1454 newdir();
11378 1454 dashing=false;
11379 1454 }
11380
11381 37515 zfix div = step;
11382
11383
1/2
✓ Branch 0 taken 37515 times.
✗ Branch 1 not taken.
37515 if(div == 0)
11384 div = 1;
11385
11386 37515 clk3=(int32_t)(16.0/div);
11387 37515 return;
11388 }
11389
11390 881364 move(step);
11391 881364 --clk3;
11392 984687 }
11393
11394 796110 void eStalfos::vire_hop()
11395 {
11396
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11397 {
11398
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11399 {
11400
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11401 3843 }
11402 376292 }
11403 417076 else sclk=0;
11404
11405
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11406 31892 return;
11407
11408 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11409 int32_t jump_height;
11410
11411
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11412 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11413 else jump_height = dmisc10;
11414
11415 761476 y=floor_y;
11416
11417
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11418 {
11419 26258 fix_coords();
11420
11421 //z=0;
11422 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11423 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11424
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11425 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11426
11427
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11428 {
11429 //z=0;
11430
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11431 {
11432
11433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11434 17258 }
11435 21336 }
11436
11437
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11438 {
11439 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11440 7030 }
11441
11442 26258 clk3=int32_t(16.0/step.getFloat());
11443 26258 }
11444
11445 761476 --clk3;
11446
11447
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11448 761476 move(step);
11449
11450 761476 floor_y=y;
11451 761476 clk2--;
11452
11453 //if we're in the middle of a jump
11454
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11455 {
11456 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11457
11458
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11459 {
11460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11461 93147 else z=h;
11462 93147 }
11463 else
11464 {
11465 384731 y=floor_y-h;
11466 384731 shadowdistance=h;
11467 }
11468 477878 }
11469 else
11470 283598 shadowdistance = 0;
11471 796110 }
11472
11473 138 void eStalfos::eathero()
11474 {
11475
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11476 {
11477 70 hashero=true;
11478 70 y=floor_y;
11479 70 z=0;
11480
11481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11482 {
11483 Hero.setX(x);
11484 Hero.setY(y);
11485 }
11486 else
11487 {
11488 70 x=Hero.getX();
11489 70 y=Hero.getY();
11490 }
11491
11492 70 clk2=0;
11493 70 }
11494 138 }
11495
11496 1469390 bool eStalfos::WeaponOut()
11497 {
11498
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11499 {
11500
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11501 {
11502 846991 return true;
11503 }
11504 1553588 }
11505
11506 622399 return false;
11507 1469390 }
11508
11509 353006 void eStalfos::KillWeapon()
11510 {
11511
2/2
✓ Branch 0 taken 293384 times.
✓ Branch 1 taken 353006 times.
646390 for(int32_t i=0; i<Ewpns.Count(); i++)
11512 {
11513
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11514 {
11515 //only kill this Goriya's boomerang -DD
11516
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11517 {
11518 411 Ewpns.del(i);
11519 411 }
11520 810 }
11521 293384 }
11522 353006 }
11523
11524 void eStalfos::break_shield()
11525 {
11526 if(!shield)
11527 return;
11528
11529 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11530 shield=false;
11531
11532 if(get_qr(qr_BRKNSHLDTILES))
11533 o_tile=s_tile;
11534 }
11535
11536 void eStalfos::repair_shield()
11537 {
11538 if (shield)
11539 return;
11540
11541 shield = true;
11542
11543 if (get_qr(qr_BRKNSHLDTILES))
11544 {
11545 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11546 else o_tile = d->tile;
11547 }
11548 }
11549
11550 13720 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11551 13720 {
11552
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 dir=(zc_oldrand()&7)+8;
11553
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 step=0;
11554 13720 movestatus=1;
11555
3/4
✓ Branch 0 taken 10596 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10596 times.
13720 if (dmisc1 != 1 && dmisc19 > 0)
11556 {
11557 step = dmisc19/100.0;
11558 movestatus = 1;
11559 }
11560
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if (dmisc1 == 2) movestatus=2;
11561 13720 c=0;
11562 13720 clk4=0;
11563 //nets;
11564
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 init_size_flags();
11565 13720 dummy_int[1]=0;
11566 13720 }
11567
11568 3535341 bool eKeese::animate(int32_t index)
11569 {
11570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3535341 times.
3535341 if(switch_hooked) return enemy::animate(index);
11571
2/4
✓ Branch 0 taken 3535341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3535341 times.
3535341 if(fallclk||drownclk) return enemy::animate(index);
11572
2/2
✓ Branch 0 taken 124509 times.
✓ Branch 1 taken 3410832 times.
3535341 if(dying)
11573 124509 return Dead(index);
11574
11575
2/2
✓ Branch 0 taken 3384641 times.
✓ Branch 1 taken 26191 times.
3410832 if(clk==0)
11576 {
11577 26191 removearmos(x,y,ffcactivated);
11578 26191 }
11579
11580
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2385790 times.
3410832 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11581 {
11582 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11583 1025042 }
11584 else
11585 {
11586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2385790 times.
2385790 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11587 2385790 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11588 }
11589
11590
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3290494 times.
3410832 if(dmisc2 == e2tKEESETRIB)
11591 {
11592
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11593 {
11594
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11595 {
11596 105 int32_t kids = guys.Count();
11597 105 bool success = false;
11598 105 int32_t id2=dmisc3;
11599 105 success = 0 != addenemy(screen_spawned,(zfix)x,(zfix)y,id2,-24);
11600
11601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11602 {
11603
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11604 {
11605 int guycarryingitem = guys.Count()-1;
11606 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11607 itemguy = false;
11608 }
11609
11610 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11611 105 }
11612
11613 105 stop_bgsfx(index);
11614 105 return true;
11615 }
11616 else
11617 {
11618 86 clk4=0;
11619 }
11620 86 }
11621 120233 }
11622 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11623
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2444615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3290494 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11624 {
11625
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11626 {
11627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11628 {
11629 fakez=int32_t(step/zslongToFix(dstep*100));
11630 // Some variance in keese flight heights when away from Hero
11631 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11632
11633 }
11634 else
11635 {
11636 687068 z=int32_t(step/zslongToFix(dstep*100));
11637 // Some variance in keese flight heights when away from Hero
11638
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11639 }
11640 687068 }
11641 else
11642 {
11643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11644 {
11645 fakez=int32_t(step/zslongToFix(dstep*100));
11646 // Some variance in keese flight heights when away from Hero
11647 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11648
11649 }
11650 else
11651 {
11652 158811 z=int32_t(step/zslongToFix(dstep*100));
11653 // Some variance in keese flight heights when away from Hero
11654
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11655 }
11656 }
11657 845879 }
11658
11659 3410727 return enemy::animate(index);
11660 3535341 }
11661
11662 2088281 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11663 {
11664 2088281 int32_t tempy=yofs;
11665 2088281 flip = 0;
11666 2088281 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11667
11668
2/2
✓ Branch 0 taken 667695 times.
✓ Branch 1 taken 1420586 times.
2088281 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11669
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1397718 times.
2088281 if(!get_qr(qr_ENEMIESZAXIS))
11670 {
11671 1397718 yofs+=int32_t(step/zslongToFix(dstep*10));
11672 1397718 }
11673
11674
6/6
✓ Branch 0 taken 2067591 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1390771 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2088281 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11675 2052223 enemy::drawshadow(dest, translucent);
11676 2088281 yofs=tempy;
11677 2088281 }
11678
11679 7949863 void eKeese::draw(BITMAP *dest)
11680 {
11681 7949863 update_enemy_frame();
11682 7949863 enemy::draw(dest);
11683 7949863 }
11684
11685 13720 void eKeese::init_size_flags()
11686 {
11687 13720 SIZEflags = d->SIZEflags;
11688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11689
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11690
11691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11692
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11693
11694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11695
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11696
11697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11698
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11699
11700
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11701 // al_trace("Enemy txsz:%i\n", txsz);
11702
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11703
11704
11705
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11706
11707
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11708
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11709 {
11710 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11711 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11712 }
11713
11714
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11715 13720 }
11716
11717 20171 void eWizzrobe::submerge(bool set)
11718 {
11719
2/2
✓ Branch 0 taken 20024 times.
✓ Branch 1 taken 147 times.
20171 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11720 {
11721 20024 hxofs = set?1000:0;
11722 20024 return;
11723 }
11724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11725 147 submerged = set;
11726
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11727 76 hxofs+=1000;
11728 71 else hxofs -= 1000;
11729 20171 }
11730 5350 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11731 5350 {
11732 5350 hxofs = 0;
11733 5350 submerged = false;
11734
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 switch(dmisc1)
11735 {
11736 case 0:
11737 2992 submerge(true);
11738 2992 fading=fade_invisible;
11739 // Set clk to just before the 'reappear' threshold
11740
9/10
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2991 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1808 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1807 times.
✓ Branch 9 taken 1 times.
2992 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11741 2992 break;
11742
11743 default:
11744 2358 dir=(loadside==right)?right:left;
11745 2358 misc=-3;
11746 2358 break;
11747 }
11748
11749 //netst+2880;
11750 5350 charging=false;
11751 5350 firing=false;
11752 5350 fclk=0;
11753
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11754
1/4
✓ Branch 0 taken 5350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5350 if (SIZEflags != 0) init_size_flags();;
11755 5350 }
11756
11757 2081613 bool eWizzrobe::animate(int32_t index)
11758 {
11759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2081613 times.
2081613 if(switch_hooked) return enemy::animate(index);
11760
2/4
✓ Branch 0 taken 2081613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2081613 times.
2081613 if(fallclk||drownclk) return enemy::animate(index);
11761
2/2
✓ Branch 0 taken 38023 times.
✓ Branch 1 taken 2043590 times.
2081613 if(dying)
11762 {
11763 38023 return Dead(index);
11764 }
11765
11766
2/2
✓ Branch 0 taken 1976944 times.
✓ Branch 1 taken 66646 times.
2043590 if(clk==0)
11767 {
11768 66646 removearmos(x,y,ffcactivated);
11769 66646 }
11770
11771
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1024370 times.
2043590 if(dmisc1) // Floating
11772 {
11773 1019220 wizzrobe_attack();
11774 1019220 }
11775 else // Teleporting
11776 {
11777
5/6
✓ Branch 0 taken 1017286 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1006199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1024370 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11778 {
11779 7084 fading=0;
11780 7084 submerge(false);
11781 7084 solid_update(false);
11782 7084 }
11783
8/8
✓ Branch 0 taken 983365 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 5313 times.
✓ Branch 3 taken 5151 times.
✓ Branch 4 taken 5006 times.
✓ Branch 5 taken 4247 times.
✓ Branch 6 taken 4109 times.
✓ Branch 7 taken 3855 times.
1017286 else switch(clk)
11784 {
11785 case 0:
11786
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5123 times.
6240 if(!dmisc2)
11787 {
11788 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11789 // but should not appear on dungeon walls.
11790
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4710 times.
5123 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11791
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4486 times.
4710 else if (editorflags&ENEMY_FLAG5)
11792 {
11793 //2.10 Windrobe
11794 //randomise location and face Hero
11795 224 int32_t t=0;
11796 224 bool placed=false;
11797
11798
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11799 {
11800
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon(screen_spawned))
11801 {
11802 280 x=((zc_oldrand()%12)+2)*16;
11803 280 y=((zc_oldrand()%7)+2)*16;
11804 280 }
11805 else
11806 {
11807 87 x=((zc_oldrand()%14)+1)*16;
11808 87 y=((zc_oldrand()%9)+1)*16;
11809 }
11810
11811 367 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11812
11813
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11814 {
11815 224 placed=true;
11816 224 }
11817
11818 367 ++t;
11819 }
11820
11821
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11822 {
11823
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11824 {
11825 47 dir=down;
11826 47 }
11827 else
11828 {
11829 14 dir=up;
11830 }
11831 61 }
11832 else
11833 {
11834
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11835 {
11836 72 dir=right;
11837 72 }
11838 else
11839 {
11840 91 dir=left;
11841 }
11842 }
11843
11844
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11845 return true;
11846
11847
11848 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11849 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11850 224 }
11851 4486 else place_on_axis(true, dmisc4!=0);
11852 5123 }
11853 else
11854 {
11855 1117 int32_t t=0;
11856 1117 bool placed=false;
11857
11858
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11859 {
11860
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon(screen_spawned))
11861 {
11862 1340 x=((zc_oldrand()%12)+2)*16;
11863 1340 y=((zc_oldrand()%7)+2)*16;
11864 1340 }
11865 else
11866 {
11867 1103 x=((zc_oldrand()%14)+1)*16;
11868 1103 y=((zc_oldrand()%9)+1)*16;
11869 }
11870
11871 2443 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11872
11873
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11874 {
11875 1117 placed=true;
11876 1117 }
11877
11878 2443 ++t;
11879 }
11880
11881
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11882 {
11883
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11884 {
11885 238 dir=down;
11886 238 }
11887 else
11888 {
11889 148 dir=up;
11890 }
11891 386 }
11892 else
11893 {
11894
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11895 {
11896 340 dir=right;
11897 340 }
11898 else
11899 {
11900 391 dir=left;
11901 }
11902 }
11903
11904
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11905 return true;
11906 }
11907
11908 6240 fading=fade_flicker;
11909 6240 submerge(false);
11910 6240 solid_update(false);
11911 6240 break;
11912
11913 case 64:
11914 5313 fading=0;
11915 5313 charging=true;
11916 5313 break;
11917
11918 case 73:
11919 5151 charging=false;
11920 5151 firing=40;
11921 5151 break;
11922
11923 case 83:
11924 5006 wizzrobe_attack_for_real();
11925 5006 break;
11926
11927 case 119:
11928 4247 firing=false;
11929 4247 charging=true;
11930 4247 break;
11931
11932 case 128:
11933 4109 fading=fade_flicker;
11934 4109 charging=false;
11935 4109 break;
11936
11937 case 146:
11938 3855 fading=fade_invisible;
11939 3855 submerge(true);
11940 3855 solid_update(false);
11941
11942 [[fallthrough]];
11943 default:
11944
4/4
✓ Branch 0 taken 987060 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 980971 times.
✓ Branch 3 taken 6249 times.
987220 if(clk>=(146+zc_max(0,dmisc5)))
11945 6249 clk=-1;
11946
11947 987220 break;
11948 }
11949 }
11950
11951 2043590 return enemy::animate(index);
11952 2081613 }
11953
11954 7929 void eWizzrobe::wizzrobe_attack_for_real()
11955 {
11956
1/2
✓ Branch 0 taken 7929 times.
✗ Branch 1 not taken.
7929 if(wpn==0) // Edited enemies
11957 return;
11958
11959
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5946 times.
7929 if(dmisc2 == 0) //normal weapon
11960 {
11961 5946 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11962 5946 sfx(firesfx, pan(int32_t(x)));
11963 5946 }
11964
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11965 {
11966 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11967 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11968 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11969 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11970 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11971 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11972 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11973 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11974 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11975 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11976 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11977 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11978 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11979 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11980 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11981 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11982 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
11983 //i've compromised by making all old quest use this code chunk by default.
11984
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
11985 {
11986 995 sfx(WAV_FIRE, pan(int32_t(x)));
11987
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(int32_t(x)));
11988 else
11989 {
11990
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
11991 {
11992 19 case ewFireball: sfx(40, pan(int32_t(x))); break;
11993 case ewBrang: sfx(4, pan(int32_t(x))); break; //Ghost.zh has 0?
11994 case ewSword: sfx(20, pan(int32_t(x))); break; //Ghost.zh has 0?
11995 case ewRock: sfx(51, pan(int32_t(x))); break;
11996 68 case ewMagic: sfx(32, pan(int32_t(x))); break;
11997 case ewBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
11998 case ewSBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
11999 case ewLitBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12000 case ewLitSBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12001 case ewFireTrail: sfx(13, pan(int32_t(x))); break;
12002 420 case ewFlame: sfx(13, pan(int32_t(x))); break;
12003 case ewWind: sfx(32, pan(int32_t(x))); break;
12004 case ewFlame2: sfx(13, pan(int32_t(x))); break;
12005 case ewFlame2Trail: sfx(13, pan(int32_t(x))); break;
12006 case ewIce: sfx(44, pan(int32_t(x))); break;
12007 case ewFireball2: sfx(40, pan(int32_t(x))); break; //fireball (rising)
12008 default: sfx(WAV_FIRE, pan(int32_t(x))); break;
12009 }
12010 }
12011 995 }
12012 else
12013 {
12014 sfx(firesfx, pan(int32_t(x)));
12015 }
12016 995 }
12017
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12018 {
12019 971 int32_t bc=0;
12020
12021
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12022 {
12023
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12024 {
12025 5195 ++bc;
12026 5195 }
12027 10497 }
12028
12029
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12030 {
12031 963 int32_t kids = guys.Count();
12032 963 int32_t bats=(zc_oldrand()%3)+1;
12033
12034
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12035 {
12036 // Summon bats (or anything)
12037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(screen_spawned, x,y,dmisc3,-10, this))
12038 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12039 1965 }
12040 963 sfx(firesfx, pan(int32_t(x)));
12041 963 }
12042 971 }
12043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12044 {
12045
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies(screen_spawned)==0)
12046 {
12047 return;
12048 }
12049
12050 17 int32_t kids = guys.Count();
12051
12052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12053 {
12054 17 int32_t newguys=(zc_oldrand()%3)+1;
12055 17 bool summoned=false;
12056
12057
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12058 {
12059 32 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
12060 32 int32_t x2=0;
12061 32 int32_t y2=0;
12062
12063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12064 {
12065 36 x2=16*((zc_oldrand()%12)+2);
12066 36 y2=16*((zc_oldrand()%7)+2);
12067
12068
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12069 {
12070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
12071 {
12072 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12073
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12074 {
12075 ((enemy*)guys.spr(kids+i))->fakez = 64;
12076 ((enemy*)guys.spr(kids+i))->z = 0;
12077 }
12078 32 }
12079
12080 32 summoned=true;
12081 32 break;
12082 }
12083 4 }
12084 32 }
12085
12086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12087 {
12088 17 sfx(firesfx, pan(int32_t(x)));
12089 17 }
12090 17 }
12091 17 }
12092 7929 }
12093
12094
12095 1019220 void eWizzrobe::wizzrobe_attack()
12096 {
12097
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12098 86341 return;
12099
12100
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12101 {
12102 39538 fix_coords();
12103
12104
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12105 {
12106 case 1: //walking
12107
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12108 2644 misc=0;
12109 else
12110 {
12111 10364 clk3=16;
12112
12113
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12114 {
12115 1398 wizzrobe_newdir(0);
12116 1398 }
12117 }
12118
12119 13008 break;
12120
12121 case 2: //phasing
12122 {
12123 3903 int32_t jx=x;
12124 3903 int32_t jy=y;
12125 3903 int32_t jdir=-1;
12126
12127
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12128 {
12129 case 0:
12130 484 jx-=32;
12131 484 jy-=32;
12132 484 jdir=15;
12133 484 break;
12134
12135 case 1:
12136 472 jx+=32;
12137 472 jy-=32;
12138 472 jdir=9;
12139 472 break;
12140
12141 case 2:
12142 482 jx+=32;
12143 482 jy+=32;
12144 482 jdir=11;
12145 482 break;
12146
12147 case 3:
12148 492 jx-=32;
12149 492 jy+=32;
12150 492 jdir=13;
12151 492 break;
12152 }
12153
12154
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12155 {
12156 1140 misc=3;
12157 1140 clk3=32;
12158 1140 dir=jdir;
12159 1140 break;
12160 }
12161 2763 }
12162 [[fallthrough]];
12163 case 3:
12164 3813 dir&=3;
12165 3813 misc=0;
12166 [[fallthrough]];
12167 case 0:
12168 19894 wizzrobe_newdir(64);
12169 [[fallthrough]];
12170 default:
12171
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12172 {
12173
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12174 {
12175 3265 misc=1;
12176 3265 clk3=16;
12177 3265 }
12178 else
12179 {
12180 239 wizzrobe_newdir(64);
12181 239 misc=0;
12182 239 clk3=32;
12183 }
12184 3504 }
12185 else
12186 {
12187 21886 clk3=32;
12188 }
12189
12190 25390 break;
12191 }
12192
12193
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12194 4478 ++misc;
12195 39538 }
12196
12197 932879 --clk3;
12198
12199
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12200 {
12201 case 1:
12202 case 3:
12203 248377 step=1;
12204 248377 break;
12205
12206 case 2:
12207 63903 step=0;
12208 63903 break;
12209
12210 default:
12211 620599 step=0.5;
12212 620599 break;
12213
12214 }
12215
12216 932879 move(step);
12217
12218 // if(d->misc1 && misc<=0 && clk3==28)
12219
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12220 {
12221
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12222 {
12223
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12224 {
12225 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12226 // sfx(WAV_WAND,pan(int32_t(x)));
12227 1928 wizzrobe_attack_for_real();
12228 1928 fclk=30;
12229 1928 }
12230 16835 }
12231 else
12232 {
12233
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12234 {
12235 995 wizzrobe_attack_for_real();
12236 995 fclk=30;
12237 995 }
12238 }
12239 21547 }
12240
12241
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12242 4050 misc=2;
12243
12244
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12245 3441 fix_coords();
12246
12247
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12248 {
12249
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12250 {
12251 83282 --fclk;
12252 83282 }
12253 932879 }
12254
12255 1019220 }
12256
12257 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12258 {
12259 // Wizzrobes shouldn't move to the edge of the screen;
12260 // if they're already there, they should move toward the center
12261
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12262 33 dir=right;
12263
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=world_w-32)
12264 4 dir=left;
12265
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12266 2 dir=down;
12267
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=world_h-32)
12268 5 dir=up;
12269 else
12270 21487 newdir(4,homing,spw_wizzrobe);
12271 21531 }
12272
12273 2099229 void eWizzrobe::draw(BITMAP *dest)
12274 {
12275 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12276
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1056746 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2099229 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12277 125018 return;
12278
12279 1974211 int32_t tempint=dummy_int[1];
12280 1974211 bool tempbool1=dummy_bool[1];
12281 1974211 bool tempbool2=dummy_bool[2];
12282 1974211 dummy_int[1]=fclk;
12283 1974211 dummy_bool[1]=charging;
12284 1974211 dummy_bool[2]=firing;
12285 1974211 update_enemy_frame();
12286 1974211 dummy_int[1]=tempint;
12287 1974211 dummy_bool[1]=tempbool1;
12288 1974211 dummy_bool[2]=tempbool2;
12289 1974211 enemy::draw(dest);
12290 2099229 }
12291
12292 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12293 203 {
12294 203 fading=fade_flash_die;
12295
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12296 {
12297 3 dir=up;
12298 3 }
12299
12300
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12301 {
12302 dir=left;
12303 }
12304
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12305 203 }
12306
12307 125855 bool eDodongo::animate(int32_t index)
12308 {
12309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12310
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12311 {
12312 3790 return Dead(index);
12313 }
12314
12315
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12316 {
12317 569 removearmos(x,y,ffcactivated);
12318 569 }
12319
12320
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12321 {
12322
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12323 113 hp-=misc; // store bomb's power in misc
12324 10848 }
12325 else
12326 111217 constant_walk(rate,homing,spw_clipright);
12327
12328 122065 hit_width = (dir<=down) ? 16 : 32;
12329 // hysz = (dir>=left) ? 16 : 32;
12330
12331 122065 return enemy::animate(index);
12332 125855 }
12333
12334 125845 void eDodongo::draw(BITMAP *dest)
12335 {
12336 125845 tile=o_tile;
12337
12338
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12339 {
12340 3065 enemy::drawzcboss(dest);
12341 3065 return;
12342 }
12343
12344 122780 update_enemy_frame();
12345 122780 enemy::drawzcboss(dest);
12346
12347
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12348 {
12349 71118 tile+=dummy_int[1]; //second tile is previous tile
12350 71118 xofs-=16; //new xofs change
12351 71118 enemy::drawzcboss(dest);
12352 71118 xofs+=16;
12353 71118 }
12354
12355 125845 }
12356
12357 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12358 {
12359 8218 int32_t wpnId = w->id;
12360 8218 int32_t power = w->power;
12361 8218 int32_t wpnx = w->x;
12362 8218 int32_t wpny = w->y;
12363
12364
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12365 5761 return 0;
12366
12367
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12368 {
12369 case wPhantom:
12370 return 0;
12371
12372 case wFire:
12373 case wBait:
12374 case wWhistle:
12375 case wWind:
12376 case wSSparkle:
12377 case wFSparkle:
12378 return 0;
12379
12380 case wLitBomb:
12381 case wLitSBomb:
12382
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12383 690 return 0;
12384
12385 113 clk2=96;
12386 113 misc=power;
12387
12388
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12389 3 item_set=isSBOMB100;
12390
12391 113 return 1;
12392
12393 case wBomb:
12394 case wSBomb:
12395
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12396 516 return 0;
12397
12398 975 stunclk=160;
12399 975 misc=wpnId; // store wpnId
12400 975 return 1;
12401
12402 case wSword:
12403
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12404 {
12405 88 sfx(WAV_EHIT,pan(int32_t(x)));
12406 88 hp=0;
12407 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12408 88 fading=0; // don't flash
12409 88 return 1;
12410 }
12411
12412 [[fallthrough]];
12413 default:
12414 75 sfx(WAV_CHINK,pan(int32_t(x)));
12415 75 }
12416
12417 75 return 1;
12418 8218 }
12419
12420 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12421 48 {
12422 48 fading=fade_flash_die;
12423 //nets+5180;
12424 48 previous_dir=-1;
12425
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12426 {
12427 1 dir=up;
12428 1 }
12429
12430
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12431 {
12432 dir=left;
12433 }
12434
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12435 48 }
12436
12437 39398 bool eDodongo2::animate(int32_t index)
12438 {
12439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12440
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12441 {
12442 1158 return Dead(index);
12443 }
12444
12445
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12446 {
12447 167 removearmos(x,y,ffcactivated);
12448 167 }
12449
12450
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12451 {
12452
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12453 42 hp-=misc; // store bomb's power in misc
12454 4032 }
12455 else
12456 34208 constant_walk(rate,homing,spw_clipbottomright);
12457
12458 38240 hit_width = (dir<=down) ? 16 : 32;
12459 38240 hit_height = (dir>=left) ? 16 : 32;
12460 38240 hxofs=(dir>=left)?-8:0;
12461 38240 hyofs=(dir<left)?-8:0;
12462
12463 38240 return enemy::animate(index);
12464 39398 }
12465
12466 39601 void eDodongo2::draw(BITMAP *dest)
12467 {
12468
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12469 {
12470 768 enemy::drawzcboss(dest);
12471 768 return;
12472 }
12473
12474 38833 int32_t tempx=xofs;
12475 38833 int32_t tempy=yofs;
12476 38833 update_enemy_frame();
12477 38833 enemy::drawzcboss(dest);
12478 38833 tile+=dummy_int[1]; //second tile change
12479 38833 xofs+=dummy_int[2]; //new xofs change
12480 38833 yofs+=dummy_int[3]; //new yofs change
12481 38833 enemy::drawzcboss(dest);
12482 38833 xofs=tempx;
12483 38833 yofs=tempy;
12484 39601 }
12485
12486 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12487 {
12488 3929 int32_t wpnId = w->id;
12489 3929 int32_t power = w->power;
12490 3929 int32_t wpnx = w->x;
12491 3929 int32_t wpny = w->y;
12492
12493
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12494 2377 return 0;
12495
12496
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12497 {
12498 case wPhantom:
12499 return 0;
12500
12501 case wFire:
12502 case wBait:
12503 case wWhistle:
12504 case wWind:
12505 case wSSparkle:
12506 case wFSparkle:
12507 346 return 0;
12508
12509 case wLitBomb:
12510 case wLitSBomb:
12511
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12512 {
12513 case up:
12514
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12515 77 return 0;
12516
12517 4 break;
12518
12519 case down:
12520
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12521 71 return 0;
12522
12523 6 break;
12524
12525 case left:
12526
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12527 66 return 0;
12528
12529 16 break;
12530
12531 case right:
12532
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12533 65 return 0;
12534
12535 16 break;
12536 }
12537
12538 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12539 // return 0;
12540 42 clk2=96;
12541 42 misc=power;
12542
12543
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12544 item_set=isSBOMB100;
12545
12546 42 return 1;
12547
12548 case wBomb:
12549 case wSBomb:
12550
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12551 {
12552 case up:
12553
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12554 84 return 0;
12555
12556 92 break;
12557
12558 case down:
12559
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12560 113 return 0;
12561
12562 55 break;
12563
12564 case left:
12565
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12566 80 return 0;
12567
12568 105 break;
12569
12570 case right:
12571
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12572 71 return 0;
12573
12574 93 break;
12575 }
12576
12577 345 stunclk=160;
12578 345 misc=wpnId; // store wpnId
12579 345 return 1;
12580
12581 case wSword:
12582
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12583 {
12584 34 sfx(WAV_EHIT,pan(int32_t(x)));
12585 34 hp=0;
12586 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12587 34 fading=0; // don't flash
12588 34 return 1;
12589 }
12590
12591 [[fallthrough]];
12592 default:
12593 158 sfx(WAV_CHINK,pan(int32_t(x)));
12594 158 }
12595
12596 158 return 1;
12597 3929 }
12598
12599 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12600 126 {
12601 //these are here to bypass compiler warnings about unused arguments
12602
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12603 {
12604
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 position_relative_to_screen(x, y, dmisc1 ? 64 : 176, 64);
12605 126 }
12606 else { x = X; y = Y; }
12607
12608 //nets+5940;
12609
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12610 {
12611 81 }
12612 else
12613 {
12614
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12615 {
12616 7 flip=1;
12617 7 }
12618 }
12619
12620
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12621 126 clk3=32;
12622 126 clk2=0;
12623 126 clk4=clk;
12624 126 dir=left;
12625
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12626 126 }
12627
12628 71899 bool eAquamentus::animate(int32_t index)
12629 {
12630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12631
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12632 2092 return Dead(index);
12633
12634 // fbx=x+((id==eRAQUAM)?4:-4);
12635
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12636 {
12637 317 removearmos(x,y,ffcactivated);
12638 317 }
12639
12640 69807 fbx=x;
12641
12642 /*
12643 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12644 {
12645 fbx+=16;
12646 }
12647 */
12648
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12649 {
12650 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12651 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12652 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12653 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12654 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12655 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12656 450 sfx(wpnsfx(wpn),pan(int32_t(x)));
12657 450 }
12658
12659
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 21018 times.
✓ Branch 3 taken 345 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12660 {
12661 345 clk3=32;
12662 345 }
12663
12664 69807 int screen_x = x.getInt()%256;
12665
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12666 {
12667 1117 int32_t d2=(zc_oldrand()%3)+1;
12668
12669
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12670 {
12671 752 dir=d2;
12672 752 }
12673
12674
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 385 times.
1117 if(dmisc1)
12675 {
12676
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(screen_x<=40)
12677 {
12678 38 dir=right;
12679 38 }
12680
12681
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(screen_x>=104)
12682 {
12683 dir=left;
12684 }
12685 385 }
12686 else
12687 {
12688
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(screen_x<=136)
12689 {
12690 21 dir=right;
12691 21 }
12692
12693
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(screen_x>=200)
12694 {
12695 34 dir=left;
12696 34 }
12697 }
12698 1117 }
12699
12700
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12701 {
12702
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12703 {
12704 4546 x-=1;
12705 4546 }
12706 else
12707 {
12708 3995 x+=1;
12709 }
12710 8541 }
12711
12712 69807 clk4=(clk4+1)%256;
12713
12714 69807 return enemy::animate(index);
12715 71899 }
12716
12717 72310 void eAquamentus::draw(BITMAP *dest)
12718 {
12719
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12720 {
12721 44994 xofs=(dmisc1?-16:0);
12722
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12723
12724
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12725 {
12726 1312 xofs=0;
12727 1312 enemy::draw(dest);
12728 1312 }
12729 else
12730 {
12731 43682 drawblock(dest,15);
12732 }
12733 44994 }
12734 else
12735 {
12736 27316 int32_t xblockofs=((dmisc1)?-16:16);
12737 27316 xofs=0;
12738
12739
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12740 {
12741 1462 enemy::draw(dest);
12742 1462 return;
12743 }
12744
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12745 {
12746 // face (0=firing, 2=resting)
12747 25854 tile=o_tile+((clk3>0)?0:2);
12748 25854 enemy::draw(dest);
12749 // tail (
12750 25854 tile=o_tile+((clk&16)?1:3);
12751 25854 xofs=xblockofs;
12752 25854 enemy::draw(dest);
12753 // body
12754 25854 yofs+=16;
12755 25854 xofs=0;
12756 25854 tile=o_tile+((clk&16)?20:22);
12757 25854 enemy::draw(dest);
12758 25854 xofs=xblockofs;
12759 25854 tile=o_tile+((clk&16)?21:23);
12760 25854 enemy::draw(dest);
12761 25854 yofs-=16;
12762 25854 }
12763 else enemy::draw(dest);
12764 }
12765 72310 }
12766
12767 23834 bool eAquamentus::hit(weapon *w)
12768 {
12769
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12770
12771
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12772 {
12773 case wBeam:
12774 case wRefBeam:
12775 case wMagic:
12776 4201 hit_height=32;
12777 4201 }
12778
12779
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12780 23834 hit_height=16;
12781 23834 return ret;
12782
12783 23834 }
12784
12785 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12786 93 {
12787
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12788 {
12789
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 position_relative_to_screen(x, y, 128, 48);
12790 93 }
12791 else { x = X; y = Y; }
12792
12793 93 Clk=Clk;
12794
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12795 {
12796 clk=0;
12797 superman = 1;
12798 fading=fade_flicker;
12799 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12800 }
12801
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12802 {
12803 42 clk=0;
12804 42 }
12805 93 hxofs=-16;
12806 93 hit_width=48;
12807 93 clk4=0;
12808
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12809
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12810
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12811
12812 //nets+5340;
12813 93 }
12814
12815 70891 bool eGohma::animate(int32_t index)
12816 {
12817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12818
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12819 1226 return Dead(index);
12820
12821
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12822 {
12823
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12824 {
12825 35 clk4=0;
12826 35 superman=0;
12827 35 fading=0;
12828 35 clk=0;
12829
12830 35 }
12831 1 else return enemy::animate(index);
12832 35 }
12833
12834
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12835 {
12836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(*ffcactivated);
12837 else
12838 {
12839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12840 350 did_armos = false;
12841 350 removearmos(x,y);
12842 350 did_armos = false;
12843
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12844 }
12845 350 }
12846
12847
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12848
12849 // Movement clk must be separate from animation clk because of the Clock item
12850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12851 68878 clk4++;
12852
12853
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12854 {
12855
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12856 546 dir^=1;
12857 else
12858 486 dir=zc_oldrand()%3+1;
12859 1032 }
12860
12861
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12862 {
12863
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12864 {
12865 case 1:
12866 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12867 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12868 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12869 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
12870 235 break;
12871
12872 default:
12873
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12874 {
12875 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12876 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12877 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12878 754 }
12879
12880 882 break;
12881 }
12882 1117 }
12883
12884
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12885 {
12886
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12887 {
12888 290 FireBreath(true);
12889 290 }
12890 2215 }
12891
12892
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12893 34479 move((zfix)1);
12894
12895
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12896 150 clk3=0;
12897
12898 68878 return enemy::animate(index);
12899 70891 }
12900
12901 70889 void eGohma::draw(BITMAP *dest)
12902 {
12903 70889 tile=o_tile;
12904
12905
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12906 {
12907 2012 enemy::drawzcboss(dest);
12908 2012 return;
12909 }
12910
12911
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12912 {
12913 ///if ( do_animation )
12914 //Yuck. Gohma can just not have this capability right now.
12915 // left side
12916 53472 xofs=-16;
12917 53472 flip=0;
12918 // if(clk&16) tile=180;
12919 // else { tile=182; flip=1; }
12920 53472 tile+=(3*((clk&48)>>4));
12921 53472 enemy::drawzcboss(dest);
12922
12923 // right side
12924 53472 xofs=16;
12925 // tile=(180+182)-tile;
12926 53472 tile=o_tile;
12927 53472 tile+=(3*((clk&48)>>4))+2;
12928 53472 enemy::drawzcboss(dest);
12929
12930 // body
12931 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12932 53472 tile=o_tile;
12933
12934 // tile+=(3*((clk&24)>>3))+2;
12935
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12936 2975 tile+=7;
12937
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12938 15890 tile+=10;
12939
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12940 2051 tile+=7;
12941 else
12942 32556 tile+=((clk3-132)&24)?4:1;
12943
12944 53472 enemy::drawzcboss(dest);
12945
12946 53472 }
12947 else
12948 {
12949 // left side
12950 15405 xofs=-16;
12951 15405 flip=0;
12952
12953
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12954 {
12955 7790 tile+=2;
12956 7790 flip=1;
12957 7790 }
12958
12959 15405 enemy::draw(dest);
12960
12961 // right side
12962 15405 tile=o_tile;
12963 15405 xofs=16;
12964
12965
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12966
12967 // tile=(180+182)-tile;
12968 15405 enemy::draw(dest);
12969
12970 // body
12971 15405 tile=o_tile;
12972 15405 xofs=0;
12973
12974
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12975 912 tile+=4;
12976
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12977 4882 tile+=5;
12978
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12979 585 tile+=4;
12980 9026 else tile+=((clk3-132)&8)?3:1;
12981
12982 15405 enemy::draw(dest);
12983
12984 }
12985 70889 }
12986
12987 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12988 {
12989 578 int32_t wpnId = w->id;
12990 578 int32_t power = w->power;
12991 578 int32_t wpnx = w->x;
12992 578 int32_t wpnDir = w->dir;
12993 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
12994
12995
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
12996 {
12997
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
12998 {
12999 93 sfx(WAV_CHINK,pan(int32_t(x)));
13000 93 return 1;
13001 }
13002 328 }
13003
13004 485 return enemy::takehit(w, realweap);
13005 578 }
13006
13007 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13008 327 {
13009 327 count_enemy=(id==(id&0xFFF));
13010 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13011
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
13012 327 }
13013
13014 124050 bool eLilDig::animate(int32_t index)
13015 {
13016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13017
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13018 4410 return Dead(index);
13019
13020
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13021 {
13022 7105 removearmos(x,y,ffcactivated);
13023 7105 }
13024
13025
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13026 {
13027
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13028 1161 step+=0.25;
13029 38646 }
13030
13031 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13032 119640 return enemy::animate(index);
13033 124050 }
13034
13035 124268 void eLilDig::draw(BITMAP *dest)
13036 {
13037 124268 tile = o_tile;
13038 // tile = 160;
13039 124268 int32_t fdiv = frate/4;
13040
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13041
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13042 124268 efrate:((clk>=(frate>>1))?1:0);
13043
13044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13045 {
13046
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13047 {
13048
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13049 {
13050 case up: //u
13051 11370 flip=0;
13052 11370 break;
13053
13054 case l_up: //d
13055 10699 flip=0;
13056 10699 tile+=4;
13057 10699 break;
13058
13059 case l_down: //l
13060 10722 flip=0;
13061 10722 tile+=8;
13062 10722 break;
13063
13064 case left: //r
13065 12015 flip=0;
13066 12015 tile+=12;
13067 12015 break;
13068
13069 case r_down: //ul
13070 10070 flip=0;
13071 10070 tile+=20;
13072 10070 break;
13073
13074 case down: //ur
13075 9554 flip=0;
13076 9554 tile+=24;
13077 9554 break;
13078
13079 case r_up: //dl
13080 8255 flip=0;
13081 8255 tile+=28;
13082 8255 break;
13083
13084 case right: //dr
13085 10033 flip=0;
13086 10033 tile+=32;
13087 10033 break;
13088 }
13089
13090 91457 tile+=f2;
13091 91457 }
13092 else
13093 {
13094 32811 tile+=(clk>=6)?1:0;
13095 }
13096 124268 }
13097
13098 124268 enemy::draw(dest);
13099 124268 }
13100
13101 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13102 80 {
13103
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13104 80 }
13105
13106 29662 bool eBigDig::animate(int32_t index)
13107 {
13108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13110 return Dead(index);
13111
13112
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13113 {
13114 4104 removearmos(x,y,ffcactivated);
13115 4104 }
13116
13117
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13118 {
13119 case 0:
13120 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13121 29534 break;
13122
13123 case 1:
13124 64 ++misc;
13125 64 break;
13126
13127 case 2:
13128
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13129 {
13130 111 addenemy(screen_spawned,x,y,dmisc1+0x1000,-15);
13131 111 }
13132
13133
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13134 {
13135 30 addenemy(screen_spawned,x,y,dmisc2+0x1000,-15);
13136 30 }
13137
13138
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13139 {
13140 30 addenemy(screen_spawned,x,y,dmisc3+0x1000,-15);
13141 30 }
13142
13143
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13144 {
13145 30 addenemy(screen_spawned,x,y,dmisc4+0x1000,-15);
13146 30 }
13147
13148
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13149 {
13150 2 int guycarryingitem = guys.Count()-1;
13151 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13152 2 itemguy = false;
13153 2 }
13154
13155 64 stop_bgsfx(index);
13156
13157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13158
13159 64 return true;
13160 }
13161
13162 29598 return enemy::animate(index);
13163 29662 }
13164
13165 29658 void eBigDig::draw(BITMAP *dest)
13166 {
13167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13168 {
13169 update_enemy_frame();
13170 xofs-=8;
13171 yofs-=8;
13172 drawblock(dest,15);
13173 xofs+=8;
13174 yofs+=8;
13175 return;
13176 }
13177
13178 29658 tile = o_tile;
13179 29658 int32_t fdiv = frate/4;
13180
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13181
13182
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13183 29658 efrate:((clk>=(frate>>1))?1:0);
13184
13185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13186 {
13187
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13188 {
13189
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13190 {
13191 case up: //u
13192 1688 flip=0;
13193 1688 break;
13194
13195 case l_up: //d
13196 1684 flip=0;
13197 1684 tile+=8;
13198 1684 break;
13199
13200 case l_down: //l
13201 2031 flip=0;
13202 2031 tile+=40;
13203 2031 break;
13204
13205 case left: //r
13206 1910 flip=0;
13207 1910 tile+=48;
13208 1910 break;
13209
13210 case r_down: //ul
13211 2041 flip=0;
13212 2041 tile+=80;
13213 2041 break;
13214
13215 case down: //ur
13216 2043 flip=0;
13217 2043 tile+=88;
13218
13219 2043 break;
13220
13221 case r_up: //dl
13222 1514 flip=0;
13223 1514 tile+=120;
13224 1514 break;
13225
13226 case right: //dr
13227 2241 flip=0;
13228 2241 tile+=128;
13229 2241 break;
13230 }
13231
13232 16161 tile+=(f2*2);
13233 16161 }
13234 else
13235 {
13236 13497 tile+=(f2)?0:2;
13237 13497 flip=(clk&1)?1:0;
13238 }
13239 29658 }
13240
13241 29658 xofs-=8;
13242 29658 yofs-=8;
13243 29658 drawblock(dest,15);
13244 29658 xofs+=8;
13245 29658 yofs+=8;
13246 29658 }
13247
13248 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13249 {
13250 869 int32_t wpnId = w->id;
13251
13252
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13253 {
13254 64 misc = 1;
13255 64 w->hit_pierce(this, 0, false);
13256 64 }
13257
13258 869 return 0;
13259 }
13260
13261 80 void eBigDig::init_size_flags()
13262 {
13263 80 SIZEflags = d->SIZEflags;
13264
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13265 // al_trace("Enemy txsz:%i\n", txsz);
13266
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13267
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13268 80 else hit_width = 32;
13269
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13270 80 else hit_height = 32;
13271
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13272 80 else hzsz = 16; // hard to jump.
13273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13274 80 else hxofs = -8;
13275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13276 80 else hyofs = -8;
13277 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13278
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13279
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13280 {
13281 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13282 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13283 }
13284
13285
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13286 80 }
13287
13288 12 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13289 12 {
13290 12 hxofs=hyofs=8;
13291
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if (editorflags & ENEMY_FLAG3)
13292 {
13293 hxofs = 4;
13294 hyofs = 4;
13295 hit_width = 24;
13296 hit_height = 24;
13297 SIZEflags|=OVERRIDE_HIT_WIDTH;
13298 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13299 }
13300 12 hzsz=16; //can't be jumped.
13301 12 clk2=70;
13302 12 misc=-1;
13303
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 mapscr* scr = get_scr(screen_spawned);
13304
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
12 mainguy=(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN));
13305 12 }
13306
13307 16559 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13308 {
13309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16559 times.
16559 if(dying)
13310
13311 return Dead(index);
13312
13313
2/2
✓ Branch 0 taken 16494 times.
✓ Branch 1 taken 65 times.
16559 if(clk==0)
13314 {
13315 65 removearmos(x,y,ffcactivated);
13316 65 }
13317
13318
6/7
✓ Branch 0 taken 3215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11541 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 902 times.
✓ Branch 5 taken 880 times.
✓ Branch 6 taken 9 times.
16559 switch(misc)
13319 {
13320 case -1:
13321 12 misc=0;
13322 [[fallthrough]];
13323 case 0:
13324
4/4
✓ Branch 0 taken 650 times.
✓ Branch 1 taken 10903 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 158 times.
11553 if(++clk2>72 && !(zc_oldrand()&3))
13325 {
13326 158 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13327 158 sfx(wpnsfx(wpn),pan(int32_t(x)));
13328 158 clk2=0;
13329 158 }
13330
13331 11553 Stunclk=0;
13332 11553 constant_walk(rate,homing,spw_none);
13333 11553 break;
13334
13335 case 1:
13336 case 2:
13337
2/2
✓ Branch 0 taken 3177 times.
✓ Branch 1 taken 38 times.
3215 if(--Stunclk<=0)
13338 {
13339 38 int32_t r=zc_oldrand();
13340
13341
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 16 times.
38 if(r&1)
13342 {
13343 16 y=96;
13344
13345
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 11 times.
16 if(r&2)
13346 5 x=160;
13347 else
13348 11 x=48;
13349
13350
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(tooclose(x,y,48))
13351 7 x=208-x;
13352
13353 16 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
13354 16 }
13355
13356 38 loadpalset(csBOSS,pSprite(d->bosspal));
13357 38 misc=0;
13358 38 }
13359
13360 3215 break;
13361
13362 case 3:
13363 {
13364
2/2
✓ Branch 0 taken 891 times.
✓ Branch 1 taken 11 times.
902 if(hclk>0)
13365 891 break;
13366
13367 11 misc=4;
13368 11 clk=0;
13369 11 hxofs=1000;
13370 11 loadpalset(9,pSprite(spPILE));
13371 11 music_stop();
13372 11 stop_sfx(WAV_ROAR);
13373
13374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13375
13376 11 sfx(WAV_GANON);
13377 //Ganon's dustpile; fall in sideview. -Z
13378 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13379 //dustpile->miscellaneous[31] = eeGANON;
13380
6/12
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 11 times.
✗ Branch 11 not taken.
11 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13381 11 item *dustpile = NULL;
13382 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13383 11 dustpile = (item *)items.spr(items.Count() - 1);
13384 11 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13385 11 break;
13386 }
13387
13388 case 4:
13389
2/2
✓ Branch 0 taken 869 times.
✓ Branch 1 taken 11 times.
880 if(clk>=80)
13390 {
13391 11 misc=5;
13392
13393 //game->lvlitems[dlevel]|=liBOSS;
13394
13395 11 sfx(WAV_CLEARED);
13396 //Add the big TF over the ashes!
13397
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 11 times.
33 for(word q = 0; q < items.Count(); q++)
13398 {
13399 22 item *ashes = (item*)items.spr(q);
13400
3/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 11 times.
22 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13401 {
13402 //Z_scripterrlog("Found correct dustpile!\n");
13403
4/8
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
11 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13404 11 item *bigtriforce = NULL;
13405 11 bigtriforce = (item *)items.spr(items.Count() - 1);
13406 11 bigtriforce->linked_parent = eeGANON;
13407 11 }
13408 22 }
13409 11 }
13410
13411 880 break;
13412 9 case 5: return true;
13413 }
13414
13415 16550 return enemy::animate(index);
13416 16559 }
13417
13418
13419 840 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13420 {
13421 //these are here to bypass compiler warnings about unused arguments
13422 840 int32_t wpnId = w->id;
13423 840 int32_t power = w->power;
13424 840 int32_t enemyHitWeapon = w->parentitem;
13425
13426
3/3
✓ Branch 0 taken 639 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 129 times.
840 switch(misc)
13427 {
13428 case 0:
13429
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 49 times.
72 if(wpnId!=wSword)
13430 23 return 0;
13431
13432 49 hp-=power;
13433
13434
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 11 times.
49 if(hp>0)
13435 {
13436 38 misc=1;
13437 38 Stunclk=64;
13438 38 }
13439 else
13440 {
13441 11 loadpalset(csBOSS,pSprite(spBROWN));
13442 11 misc=2;
13443 11 Stunclk=284;
13444 11 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13445 }
13446
13447 49 sfx(WAV_EHIT,pan(int32_t(x)));
13448
13449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13450
13451 49 return 1;
13452
13453 case 2:
13454
4/6
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
129 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13455 118 return 0;
13456
13457 11 misc=3;
13458 11 hclk=81;
13459 11 loadpalset(9,pSprite(spBROWN));
13460 11 return 1;
13461 }
13462
13463 639 return 0;
13464 840 }
13465
13466 18887 void eGanon::draw(BITMAP *dest)
13467 {
13468
6/6
✓ Branch 0 taken 3334 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 783 times.
✓ Branch 3 taken 2340 times.
✓ Branch 4 taken 11541 times.
✓ Branch 5 taken 880 times.
18887 switch(misc)
13469 {
13470 case 0:
13471
2/2
✓ Branch 0 taken 8657 times.
✓ Branch 1 taken 2884 times.
11541 if((clk&3)==3)
13472 2884 tile=(zc_oldrand()%5)*2+o_tile;
13473
13474
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11541 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11541 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13475 {
13476
13477 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13478 {
13479 int odraw = drawstyle;
13480 drawstyle = 2;
13481 drawblock(dest,15);
13482 drawstyle = odraw;
13483 }
13484 else
13485 {
13486 drawblock(dest,15);
13487 }
13488 break;
13489
13490 }
13491
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11541 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11541 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13492 {
13493 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13494 {
13495 int odraw = drawstyle;
13496 drawstyle = 2;
13497 drawblock(dest,15);
13498 drawstyle = odraw;
13499 }
13500 else
13501 {
13502 drawblock(dest,15);
13503 }
13504 break;
13505 }
13506
1/2
✓ Branch 0 taken 11541 times.
✗ Branch 1 not taken.
11541 if(db!=999)
13507 11541 break;
13508 [[fallthrough]];
13509 case 2:
13510
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 783 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
783 if(Stunclk<64 && (Stunclk&1))
13511 break;
13512 [[fallthrough]];
13513 case -1:
13514 3123 tile=o_tile;
13515
13516 [[fallthrough]];
13517 case 1:
13518 case 3:
13519 6457 drawblock(dest,15);
13520 6457 break;
13521
13522 case 4:
13523 880 draw_guts(dest);
13524 880 draw_flash(dest);
13525 880 break;
13526 }
13527 18887 }
13528
13529 880 void eGanon::draw_guts(BITMAP *dest)
13530 {
13531
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 187 times.
880 int32_t c = zc_min(clk>>3,8);
13532 880 tile = clk<24 ? 74 : 75;
13533 880 overtile16(dest,tile,x+8-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13534 880 overtile16(dest,tile,x+8-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13535 880 overtile16(dest,tile,x+c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13536 880 overtile16(dest,tile,x+16-c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13537 880 overtile16(dest,tile,x+c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13538 880 overtile16(dest,tile,x+16-c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13539 880 overtile16(dest,tile,x+c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13540 880 overtile16(dest,tile,x+16-c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13541 880 }
13542
13543 880 void eGanon::draw_flash(BITMAP *dest)
13544 {
13545
13546 880 int32_t c = clk-(clk>>2);
13547 880 cs = (frame&3)+6;
13548 880 overtile16(dest,194,x+8-viewport.x,y+8-clk+playing_field_offset-viewport.y,cs,0);
13549 880 overtile16(dest,194,x+8-viewport.x,y+8+clk+playing_field_offset-viewport.y,cs,2);
13550 880 overtile16(dest,195,x+8-clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,0);
13551 880 overtile16(dest,195,x+8+clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,1);
13552 880 overtile16(dest,196,x+8-c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,0);
13553 880 overtile16(dest,196,x+8+c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,1);
13554 880 overtile16(dest,196,x+8-c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,2);
13555 880 overtile16(dest,196,x+8+c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,3);
13556 880 }
13557
13558 14 void getBigTri(mapscr* scr, int32_t id2)
13559 {
13560 /*
13561 *************************
13562 * BIG TRIFORCE SEQUENCE *
13563 *************************
13564 0 BIGTRI out, WHITE flash in
13565 4 WHITE flash out, PILE cset white
13566 8 WHITE in
13567 ...
13568 188 WHITE out
13569 191 PILE cset red
13570 200 top SHUTTER opens
13571 209 bottom SHUTTER opens
13572 */
13573 14 sfx(itemsbuf[id2].playsound);
13574 14 guys.clear();
13575
13576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(itemsbuf[id2].flags & item_gamedata)
13577 {
13578 game->lvlitems[dlevel]|=liTRIFORCE;
13579 }
13580
13581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13582
13583 14 draw_screen();
13584
13585
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 2688 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 2688 times.
2702 for(int32_t f=0; f<24*8 && !Quit; f++)
13586 {
13587
2/2
✓ Branch 0 taken 2674 times.
✓ Branch 1 taken 14 times.
2688 if(f==4)
13588 {
13589
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 14 times.
224 for(int32_t i=1; i<16; i++)
13590 {
13591 210 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13592 210 }
13593 14 }
13594
13595
2/2
✓ Branch 0 taken 2352 times.
✓ Branch 1 taken 336 times.
2688 if((f&7)==0)
13596 {
13597
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 for(int32_t cs=2; cs<5; cs++)
13598 {
13599
2/2
✓ Branch 0 taken 15120 times.
✓ Branch 1 taken 1008 times.
16128 for(int32_t i=1; i<16; i++)
13600 {
13601 15120 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13602 15120 }
13603 1008 }
13604
13605 336 refreshpal=true;
13606 336 }
13607
13608
2/2
✓ Branch 0 taken 2352 times.
✓ Branch 1 taken 336 times.
2688 if((f&7)==4)
13609 {
13610
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
13611 else loadlvlpal(0xB);
13612 336 }
13613
13614
2/2
✓ Branch 0 taken 2674 times.
✓ Branch 1 taken 14 times.
2688 if(f==191)
13615 {
13616 14 loadpalset(9,pSprite(spPILE));
13617 14 }
13618
13619 2688 advanceframe(true);
13620 2688 }
13621
13622 //play_DmapMusic();
13623 14 playLevelMusic();
13624
13625
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
14 if(itemsbuf[id2].flags & item_flag1 && cur_screen < 128)
13626 {
13627 2 Hero.dowarp(hero_scr, 1, 0); //side warp
13628 2 }
13629 14 }
13630
13631 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13632 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13633 618 {
13634
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13635 {
13636
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 position_relative_to_screen(x, y, 128, 48);
13637 618 }
13638 //else { x = X; y = Y; }
13639
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13640 618 superman=1;
13641 618 fading=fade_invisible;
13642 618 hxofs=1000;
13643 618 segcnt=clk;
13644 618 segid=Id|0x1000;
13645 618 clk=0;
13646
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13647
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13648 618 tile=o_tile;
13649 618 hitdir = -1;
13650 618 stickclk = 0;
13651
13652 /*
13653 if (get_qr(qr_NEWENEMYTILES))
13654 {
13655 tile=nets+1220;
13656 }
13657 else
13658 {
13659 tile=57;
13660 }
13661 */
13662 618 }
13663
13664 244844 bool eMoldorm::animate(int32_t index)
13665 {
13666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13667 244844 int32_t max_y = isdungeon(screen_spawned) ? 100 : 100+28; //warning: Ugly hack. -Z
13668
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13669 {
13670 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13671 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13672 28475 }
13673
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13674 {
13675 562 stickclk = 0;
13676 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13677 562 }
13678
13679
13680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13681 {
13682 244844 removearmos(x,y,ffcactivated);
13683 244844 }
13684
13685
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13686 {
13687
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13688 {
13689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13690 129 never_return(screen_spawned, index);
13691
13692
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13693 129 leave_item();
13694
13695 129 stop_bgsfx(index);
13696 129 return true;
13697 }
13698 2322 }
13699 else
13700 {
13701
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13702 stunclk=0;
13703 242393 constant_walk_8_old(rate,homing,spw_floater);
13704
13705
13706 242393 misc=dir;
13707
13708 // If any higher-numbered segments were killed, segcnt can be too high,
13709 // leading to a crash
13710
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13711 segcnt=guys.Count()-index-1;
13712
13713
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
13714 {
13715 1122281 enemy* segment=((enemy*)guys.spr(i));
13716
13717 // More validation - if segcnt was wrong, this may not
13718 // actually be a Moldorm segment
13719
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
13720 {
13721 segcnt=i-index-1;
13722 break;
13723 }
13724
13725
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
13726 {
13727 242669 x=segment->x;
13728 242669 y=segment->y;
13729 242669 }
13730
13731 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
13732 //Script your own blasted segmented bosses!! -Z
13733 1122281 segment->setParent(this);
13734
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
13735 {
13736 217733 segment->dummy_int[1]=2;
13737 217733 }
13738 else
13739 {
13740 904548 segment->dummy_int[1]=1;
13741 }
13742
13743
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
13744 {
13745 242669 segment->dummy_int[1]=0;
13746 242669 }
13747
13748
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
13749 {
13750 1016 int32_t offset=1;
13751
13752
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
13753 {
13754 // Triple-check
13755
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
13756 {
13757 segcnt=j-index+1; // Add 1 because of --segcnt below
13758 break;
13759 }
13760 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13761 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13762 1480 }
13763
13764 1016 segment->hclk=33;
13765 1016 --segcnt;
13766 1016 --i; // Recheck the same index in case multiple segments died at once
13767 1016 }
13768 1122281 }
13769
13770
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
13771 {
13772 129 clk2=19;
13773
13774 129 x=guys.spr(index+1)->x;
13775 129 y=guys.spr(index+1)->y;
13776 129 }
13777 }
13778
13779 244715 return false;
13780 244844 }
13781
13782 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13783 3150 {
13784
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
13785 {
13786
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 position_relative_to_screen(x, y, 128, 48);
13787 3150 }
13788
13789
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13790 3150 hyofs=4;
13791 3150 hit_width=hit_height=8;
13792 3150 hxofs=1000;
13793 3150 mainguy=count_enemy=false;
13794 3150 parentclk = 0;
13795 3150 bgsfx=-1;
13796
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
13797 //deadsfx = WAV_EDEAD;
13798 3150 isCore = false;
13799 3150 }
13800
13801 1138024 bool esMoldorm::animate(int32_t index)
13802 {
13803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
13804 // Shouldn't be possible, but better to be sure
13805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
13806 dying=true;
13807
13808
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
13809 {
13810
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
13811 15743 item_set=0;
13812
13813 15743 return Dead(index);
13814 }
13815
13816
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
13817 {
13818 1017204 hxofs=4;
13819 1017204 step=((enemy*)guys.spr(index-1))->step;
13820
13821
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
13822 {
13823 70455 misc=dir;
13824 70455 dir=((enemy*)guys.spr(index-1))->misc;
13825 //do alignment, as in parent's animation :-/ -DD
13826 70455 x.doFloor();
13827 70455 y.doFloor();
13828 70455 }
13829
13830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
13831 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
13832
13833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
13834 {
13835 1017204 sprite::move(step);
13836 1017204 }
13837 1017204 }
13838
13839 1122281 return enemy::animate(index);
13840 1138024 }
13841
13842 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
13843 {
13844
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
13845 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
13846
13847 453 return 0;
13848 2683 }
13849
13850 1155313 void esMoldorm::draw(BITMAP *dest)
13851 {
13852 1155313 tile=o_tile;
13853 1155313 int32_t fdiv = frate/4;
13854
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13855
13856
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13857 1155313 efrate:((clk>=(frate>>1))?1:0);
13858
13859
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
13860 {
13861 1043930 tile+=dummy_int[1]*40;
13862
13863
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
13864 {
13865 102730 flip=0;
13866
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
13867
13868
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
13869 tile+=4;
13870 102730 }
13871 else
13872 {
13873
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
13874 {
13875 case up: //u
13876 96530 flip=0;
13877 96530 break;
13878
13879 case l_up: //d
13880 134534 flip=0;
13881 134534 tile+=4;
13882 134534 break;
13883
13884 case l_down: //l
13885 113426 flip=0;
13886 113426 tile+=8;
13887 113426 break;
13888
13889 case left: //r
13890 124800 flip=0;
13891 124800 tile+=12;
13892 124800 break;
13893
13894 case r_down: //ul
13895 101314 flip=0;
13896 101314 tile+=20;
13897 101314 break;
13898
13899 case down: //ur
13900 99043 flip=0;
13901 99043 tile+=24;
13902 99043 break;
13903
13904 case r_up: //dl
13905 131794 flip=0;
13906 131794 tile+=28;
13907 131794 break;
13908
13909 case right: //dr
13910 139759 flip=0;
13911 139759 tile+=32;
13912 139759 break;
13913 }
13914 }
13915
13916 1043930 tile+=f2;
13917 1043930 }
13918
13919
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
13920 1049046 enemy::draw(dest);
13921 1155313 }
13922
13923 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13924 420 {
13925
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
13926 {
13927
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 position_relative_to_screen(x, y, 64, 80);
13928 420 }
13929 //else { x = X; y = Y; }
13930 //byte legaldirs = 0;
13931 420 int32_t incr = 16;
13932 //int32_t possiiblepos = 0;
13933 //int32_t positions[8] = {0};
13934
13935 //Don't spawn in pits.
13936
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
13937 {
13938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
13939 {
13940 //move if we spawn over a pit
13941 //check each direction
13942
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
13943 {
13944
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
13945 }
13946
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
13947 {
13948
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
13949 }
13950
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
13951 {
13952
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
13953 }
13954
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
13955 {
13956
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
13957 }
13958
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
13959 {
13960 y -= incr; break;
13961 }
13962
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
13963 {
13964 y+=incr; break;
13965 }
13966
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
13967 {
13968
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
13969 }
13970
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
13971 {
13972 x+=incr; y+=incr; break;
13973 }
13974 34 else continue;
13975
13976 }
13977
13978 105 }
13979
13980 420 dir=up;
13981 420 superman=1;
13982 420 fading=fade_invisible;
13983 420 hxofs=1000;
13984 420 segcnt=clk;
13985 420 clk=0;
13986 //set up move history
13987
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
13988
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
13989 420 }
13990
13991 236907 bool eLanmola::animate(int32_t index)
13992 {
13993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
13994
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
13995 {
13996 40196 removearmos(x,y,ffcactivated);
13997 40196 }
13998
13999
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
14000 {
14001
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
14002 {
14003
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14004 86 leave_item();
14005
14006 189 stop_bgsfx(index);
14007 189 return true;
14008 }
14009
14010 3402 return false;
14011 }
14012
14013
14014 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14015 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14016 //I've added a complete movement history to this enemy to compensate -DD
14017 233316 constant_walk(rate,homing,spw_none);
14018 233316 prevState.pop_front();
14019 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14020
14021 // This could cause a crash with Moldorms. I didn't see the same problem
14022 // with Lanmolas, but it looks like it ought to be possible, so here's
14023 // the same solution. - Saf
14024
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14025 segcnt=guys.Count()-index-1;
14026
14027
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14028 {
14029 966396 enemy* segment=((enemy*)guys.spr(i));
14030
14031 // More validation in case segcnt is wrong
14032
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14033 {
14034 segcnt=i-index-1;
14035 break;
14036 }
14037
14038 966396 segment->o_tile=o_tile;
14039 966396 segment->setParent(this);
14040
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14041 {
14042 195700 segment->dummy_int[1]=1; //tail
14043 195700 }
14044 else
14045 {
14046 770696 segment->dummy_int[1]=0;
14047 }
14048
14049
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14050 {
14051
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14052 {
14053 // Triple-check
14054
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14055 {
14056 segcnt=j-index+1; // Add 1 because of --segcnt below
14057 break;
14058 }
14059 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14060 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14061 1961 }
14062
14063 1169 ((enemy*)guys.spr(i))->hclk=33;
14064 1169 --segcnt;
14065 1169 --i; // Recheck the same index in case multiple segments died at once
14066 1169 }
14067 966396 }
14068
14069
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14070 {
14071 189 clk2=19;
14072 189 x=guys.spr(index+1)->x;
14073 189 y=guys.spr(index+1)->y;
14074 189 setmapflag(get_scr(screen_spawned), mTMPNORET);
14075 189 }
14076
14077 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14078 //which is... disastrous.
14079 233316 hp = 1;
14080 233316 return enemy::animate(index);
14081 236907 }
14082
14083 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14084 2267 {
14085
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14086 {
14087
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 position_relative_to_screen(x, y, 64, 80);
14088 2267 }
14089 2267 int32_t incr = 16;
14090 //Don't spawn in pits.
14091
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14092 {
14093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14094 {
14095 //move if we spawn over a pit
14096 //check each direction
14097
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14098 {
14099
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14100 }
14101
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14102 {
14103
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14104 }
14105
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14106 {
14107
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14108 }
14109
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14110 {
14111
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14112 }
14113
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14114 {
14115 y -= incr; break;
14116 }
14117
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14118 {
14119 y+=incr; break;
14120 }
14121
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14122 {
14123
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14124 }
14125
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14126 {
14127 x+=incr; y+=incr; break;
14128 }
14129 170 else continue;
14130
14131 }
14132
14133 525 }
14134
14135 2267 hxofs=1000;
14136 2267 hit_width=8;
14137 2267 mainguy=false;
14138 2267 count_enemy=(id<0x2000)?true:false;
14139
14140 //set up move history
14141
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14142
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14143
14144 2267 bgsfx = -1;
14145 2267 isCore = false;
14146
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14147 2267 }
14148
14149 985563 bool esLanmola::animate(int32_t index)
14150 {
14151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14152 // Shouldn't be possible, but who knows
14153
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14154 18 dying=true;
14155
14156
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14157 {
14158 19167 xofs=0;
14159
14160
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14161 9306 item_set=0;
14162
14163 19167 return Dead(index);
14164 }
14165
14166
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14167 {
14168 930450 hxofs=4;
14169
14170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14171 {
14172 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14173 930450 prevState.pop_front();
14174 930450 prevState.push_back(newstate);
14175 930450 x = newstate.first.first;
14176 930450 y = newstate.first.second;
14177 930450 dir = newstate.second;
14178 930450 }
14179 930450 }
14180
14181 966396 return enemy::animate(index);
14182 985563 }
14183
14184 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14185 {
14186
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14187 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14188
14189 590 return 0;
14190 2655 }
14191
14192 990931 void esLanmola::draw(BITMAP *dest)
14193 {
14194 990931 tile=o_tile;
14195 990931 int32_t fdiv = frate/4;
14196
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14197
14198
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14199 990931 efrate:((clk>=(frate>>1))?1:0);
14200
14201
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14202 {
14203
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14204 {
14205 481767 tile+=20;
14206
14207
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14208 {
14209 128742 tile+=20;
14210 128742 }
14211 481767 }
14212
14213
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14214 {
14215 case up:
14216 141419 flip=0;
14217 141419 break;
14218
14219 case down:
14220 140994 flip=0;
14221 140994 tile+=4;
14222 140994 break;
14223
14224 case left:
14225 159500 flip=0;
14226 159500 tile+=8;
14227 159500 break;
14228
14229 case right:
14230 187019 flip=0;
14231 187019 tile+=12;
14232 187019 break;
14233 }
14234
14235 628932 tile+=f2;
14236 628932 }
14237 else
14238 {
14239
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14240 {
14241 271456 tile+=1;
14242 271456 }
14243 }
14244
14245
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14246 953893 enemy::draw(dest);
14247 990931 }
14248
14249 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14250 150 {
14251 //these are here to bypass compiler warnings about unused arguments
14252 150 Clk=Clk;
14253 150 superman=1;
14254
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14255 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14256
14257
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14258 692 arm[i]=i;
14259
14260 150 fading=fade_blue_poof;
14261 //nets+4680;
14262 150 adjusted=false;
14263
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14264 150 }
14265
14266 66494 bool eManhandla::animate(int32_t index)
14267 {
14268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14269
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14270 1382 return Dead(index);
14271
14272
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14273 {
14274 2471 removearmos(x,y,ffcactivated);
14275 2471 }
14276
14277
14278 // check arm status, move dead ones to end of group
14279
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14280 {
14281 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14282
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14283 {
14284
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14285 {
14286 552 zc_swap(arm[j],arm[j+1]);
14287 552 guys.swap(index+j+1,index+j+2);
14288 552 }
14289
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14290 {
14291 87 leave_item();
14292 87 }
14293 424 --armcnt;
14294 424 --i;
14295 424 continue;
14296 }
14297
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14298 {
14299
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14300 {
14301 508 cur_arm->o_tile=o_tile+40;
14302 508 cur_arm->setParent(this);
14303 508 }
14304 else
14305 {
14306 184 cur_arm->o_tile=o_tile+160;
14307 184 cur_arm->setParent(this);
14308 }
14309 692 }
14310 193194 }
14311
14312 65112 adjusted=true;
14313
14314 // move or die
14315
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14316 83 hp=0;
14317 else
14318 {
14319 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14320
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14321
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14322 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14323
14324
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14325 {
14326
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14327 {
14328
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14329 {
14330 case 0:
14331 38579 dy1=-24;
14332 38579 break;
14333
14334 case 1:
14335 36328 dy2=31;
14336 36328 break;
14337
14338 case 2:
14339 36250 dx1=-16;
14340 36250 break;
14341
14342 case 3:
14343 39862 dx2=31;
14344 39862 break;
14345 }
14346 151019 }
14347 53584 }
14348 else
14349 {
14350 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14351
14352
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14353 {
14354
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14355 {
14356 case 0:
14357 12012 dy1=-32;
14358 12012 break;
14359
14360 case 1:
14361 7730 dy2=39;
14362 7730 break;
14363
14364 case 2:
14365 9837 dx1=-24;
14366 9837 break;
14367
14368 case 3:
14369 12596 dx2=39;
14370 12596 break;
14371 }
14372 42175 }
14373 }
14374
14375 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14376
14377
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14378 {
14379 193194 zfix dx=(zfix)0,dy=(zfix)0;
14380
14381
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14382 {
14383
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14384 {
14385 case 0:
14386 38579 dy=-16;
14387 38579 break;
14388
14389 case 1:
14390 36328 dy=16;
14391 36328 break;
14392
14393 case 2:
14394 36250 dx=-16;
14395 36250 break;
14396
14397 case 3:
14398 39862 dx=16;
14399 39862 break;
14400 }
14401 151019 }
14402 else
14403 {
14404
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14405 {
14406 case 0:
14407 5447 dy=-24;
14408 5447 dx=-8;
14409 5447 break;
14410
14411 case 1:
14412 3986 dy=24;
14413 3986 dx=8;
14414 3986 break;
14415
14416 case 2:
14417 4163 dx=-24;
14418 4163 dy=8;
14419 4163 break;
14420
14421 case 3:
14422 6774 dx=24;
14423 6774 dy=-8;
14424 6774 break;
14425
14426 case 4:
14427 6565 dy=-24;
14428 6565 dx=8;
14429 6565 break;
14430
14431 case 5:
14432 3744 dy=24;
14433 3744 dx=-8;
14434 3744 break;
14435
14436 case 6:
14437 5674 dx=-24;
14438 5674 dy=-8;
14439 5674 break;
14440
14441 case 7:
14442 5822 dx=24;
14443 5822 dy=8;
14444 5822 break;
14445 }
14446 }
14447
14448 193194 guys.spr(index+i+1)->x = x+dx;
14449 193194 guys.spr(index+i+1)->y = y+dy;
14450 193194 }
14451 }
14452
14453 65112 return enemy::animate(index);
14454 66494 }
14455
14456
14457 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14458 {
14459 1751 int32_t wpnId = w->id;
14460
14461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14462 return 0;
14463
14464
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14465 {
14466 case wBomb:
14467 case wSBomb:
14468 case wSword:
14469 case wHammer:
14470 case wWand:
14471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14472
14473 case wLitBomb:
14474 case wLitSBomb:
14475 case wBait:
14476 case wWhistle:
14477 case wFire:
14478 case wWind:
14479 case wSSparkle:
14480 case wFSparkle:
14481 case wPhantom:
14482 1709 return 0;
14483
14484 case wHookshot:
14485 case wBrang:
14486 sfx(WAV_CHINK,pan(int32_t(x)));
14487 break;
14488
14489 default:
14490
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14491 else sfx(WAV_CHINK,pan(int32_t(x)));
14492
14493 42 }
14494
14495 42 return 1;
14496 1751 }
14497
14498 66490 void eManhandla::draw(BITMAP *dest)
14499 {
14500 66490 tile=o_tile;
14501 66490 int32_t fdiv = frate/4;
14502
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14503
14504
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14505 66490 efrate:((clk>=(frate>>1))?1:0);
14506
14507
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14508 {
14509
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14510 {
14511
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14512 {
14513 case up: //u
14514 4771 flip=0;
14515 4771 break;
14516
14517 case l_up: //d
14518 4640 flip=0;
14519 4640 tile+=4;
14520 4640 break;
14521
14522 case l_down: //l
14523 4995 flip=0;
14524 4995 tile+=8;
14525 4995 break;
14526
14527 case left: //r
14528 5574 flip=0;
14529 5574 tile+=12;
14530 5574 break;
14531
14532 case r_down: //ul
14533 3793 flip=0;
14534 3793 tile+=20;
14535 3793 break;
14536
14537 case down: //ur
14538 3930 flip=0;
14539 3930 tile+=24;
14540 3930 break;
14541
14542 case r_up: //dl
14543 3908 flip=0;
14544 3908 tile+=28;
14545 3908 break;
14546
14547 case right: //dr
14548 5883 flip=0;
14549 5883 tile+=32;
14550 5883 break;
14551 }
14552
14553 37494 tile+=f2;
14554 37494 enemy::draw(dest);
14555 37494 } //manhandla 2, big body
14556 else
14557 {
14558
14559
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14560 {
14561 case up: //u
14562 1277 flip=0;
14563 1277 break;
14564
14565 case l_up: //d
14566 1360 flip=0;
14567 1360 tile+=8;
14568 1360 break;
14569
14570 case l_down: //l
14571 2242 flip=0;
14572 2242 tile+=40;
14573 2242 break;
14574
14575 case left: //r
14576 1789 flip=0;
14577 1789 tile+=48;
14578 1789 break;
14579
14580 case r_down: //ul
14581 1345 flip=0;
14582 1345 tile+=80;
14583 1345 break;
14584
14585 case down: //ur
14586 805 flip=0;
14587 805 tile+=88;
14588 805 break;
14589
14590 case r_up: //dl
14591 948 flip=0;
14592 948 tile+=120;
14593 948 break;
14594
14595 case right: //dr
14596 1542 flip=0;
14597 1542 tile+=128;
14598 1542 break;
14599 }
14600
14601 11308 tile+=(f2*2);
14602 11308 xofs-=8;
14603 11308 yofs-=8;
14604 11308 drawblock(dest,15);
14605 11308 xofs+=8;
14606 11308 yofs+=8;
14607 }
14608 48802 }
14609 else
14610 {
14611
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14612 {
14613 17173 enemy::draw(dest);
14614 17173 }
14615 else
14616 {
14617 515 xofs-=8;
14618 515 yofs-=8;
14619 515 enemy::draw(dest);
14620 515 xofs+=16;
14621 515 enemy::draw(dest);
14622 515 yofs+=16;
14623 515 enemy::draw(dest);
14624 515 xofs-=16;
14625 515 enemy::draw(dest);
14626 515 xofs+=8;
14627 515 yofs-=8;
14628 }
14629 }
14630 66490 }
14631
14632 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14633 692 {
14634 692 id=misc=clk;
14635 692 dir = clk & 3;
14636 692 clk=0;
14637 692 mainguy=count_enemy=false;
14638 692 dummy_bool[0]=false;
14639 692 item_set=0;
14640 692 bgsfx=-1;
14641 692 deadsfx = WAV_EDEAD;
14642
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14643 692 isCore = false;
14644
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14645 692 }
14646
14647 200202 bool esManhandla::animate(int32_t index)
14648 {
14649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14650
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14651 7008 return Dead(index);
14652
14653
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14654 {
14655 12404 removearmos(x,y,ffcactivated);
14656 12404 }
14657
14658
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14659 {
14660 27896 clk2=unsigned(zc_oldrand())%5+5;
14661 27896 clk3^=1;
14662 27896 }
14663
14664
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14665 {
14666 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14667 1491 sfx(wpnsfx(wpn),pan(int32_t(x)));
14668 1491 }
14669
14670 193194 return enemy::animate(index);
14671 200202 }
14672
14673 200186 void esManhandla::draw(BITMAP *dest)
14674 {
14675 200186 tile=o_tile;
14676 200186 int32_t fdiv = frate/4;
14677
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14678
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14679 200186 efrate:((clk>=(frate>>1))?1:0);
14680
14681
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14682 {
14683
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14684 {
14685 case up:
14686 39945 break;
14687
14688 case down:
14689 36845 tile+=4;
14690 36845 break;
14691
14692 case left:
14693 39966 tile+=8;
14694 39966 break;
14695
14696 case right:
14697 41960 tile+=12;
14698 41960 break;
14699 }
14700
14701 158716 tile+=f2;
14702 158716 }
14703 else
14704 {
14705
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14706 {
14707 case down:
14708 8961 flip=2;
14709
14710 [[fallthrough]];
14711 case up:
14712 21355 tile=(clk3)?188:189;
14713 21355 break;
14714
14715 case right:
14716 12232 flip=1;
14717 [[fallthrough]];
14718
14719 case left:
14720 20115 tile=(clk3)?186:187;
14721 20115 break;
14722 }
14723 }
14724
14725 200186 enemy::draw(dest);
14726 200186 }
14727
14728 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
14729 168 {
14730
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
14731 {
14732
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, 120, 48);
14733 168 }
14734 else
14735 {
14736 if ( !(editorflags & ENEMY_FLAG6) )
14737 {
14738 x = X; y = Y;
14739 }
14740 else
14741 {
14742 x = X+8; y = Y;
14743 }
14744 }
14745 168 hzsz = 32; // can't be jumped.
14746 168 flameclk=0;
14747 168 misc=clk; // total head count
14748 168 clk3=clk; // live head count
14749 168 clk=0;
14750 168 clk2=60; // fire ball clock
14751 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
14752
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
14753 168 dir = down;
14754 168 hxofs=4;
14755 168 hit_width=8;
14756 // frate=17*4;
14757 168 fading=fade_blue_poof;
14758 //nets+5420;
14759
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
14760 {
14761 /*
14762 necktile=o_tile+8;
14763 if (dmisc3)
14764 {
14765 necktile+=8;
14766 }
14767 */
14768 133 necktile=o_tile+dmisc6;
14769 133 }
14770 else
14771 {
14772 35 necktile=s_tile;
14773 }
14774 168 }
14775
14776 155290 bool eGleeok::animate(int32_t index)
14777 {
14778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
14779
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
14780 2199 return Dead(index);
14781
14782
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
14783 {
14784 684 removearmos(x,y,ffcactivated);
14785 684 }
14786
14787 // Check if a head was killed somehow...
14788
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
14789 51372 clk3=guys.Count()-index-1;
14790
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
14791 87041 misc=guys.Count()-index-1;
14792
14793 //fix for the "kill all enemies" item
14794
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
14795 {
14796
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
14797 {
14798 // I haven't seen this fail, but it seems like it ought to be
14799 // possible, so I'm checking for it. - Saf
14800
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14801 break;
14802 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
14803 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
14804 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
14805 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
14806 12 }
14807
14808 6 clk3=0;
14809
14810
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
14811 {
14812
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14813 break;
14814 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14815 12 }
14816 6 }
14817
14818
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
14819 {
14820 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
14821 403171 head->dummy_int[1]=necktile;
14822 403171 head->setParent(this);
14823
14824
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
14825 {
14826 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
14827 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
14828 320127 }
14829 else
14830 {
14831 83044 head->dummy_int[2]=necktile+1; //connected head tile
14832 83044 head->dummy_int[3]=necktile+2; //flying head tile
14833 }
14834
14835 403171 head->dmisc5=dmisc5; //neck segments
14836
14837 /*
14838 if (dmisc3)
14839 {
14840 head->dummy_bool[0]=true;
14841 }
14842 */
14843
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
14844 {
14845
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
14846 {
14847 1228 hp -= 1000 - head->hp;
14848 1228 hclk = 33;
14849
14850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
14851
14852 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
14853 1228 }
14854
14855 5655 head->hclk = 0;
14856 5655 }
14857
14858 // Must be set in case of naughty ZScripts
14859 403171 head->hp = 1000;
14860 403171 }
14861
14862
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
14863 {
14864 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
14865 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
14866 415 }
14867
14868
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
14869 {
14870
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
14871 {
14872 1287 int32_t i = zc::math::SafeMod(zc_oldrand(), misc);
14873 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
14874 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
14875 1287 sfx(wpnsfx(wpn),pan(int32_t(x)));
14876 1287 clk2=0;
14877 1287 }
14878 95682 }
14879 else
14880 {
14881
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
14882 {
14883 557 enemy *head = ((enemy*)guys.spr(zc::math::SafeMod(zc_oldrand(), misc) + index + 1));
14884 557 head->timer=zc_oldrand()%50+50;
14885 557 clk2=0;
14886 557 }
14887 }
14888
14889
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
14890 {
14891
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
14892 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14893
14894
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(screen_spawned, index);
14895 127 }
14896
14897 153091 return enemy::animate(index);
14898 155290 }
14899
14900 1239 int32_t eGleeok::takehit(weapon*,weapon*)
14901 {
14902 1239 return 0;
14903 }
14904
14905 156918 void eGleeok::draw(BITMAP *dest)
14906 {
14907 156918 tile=o_tile;
14908
14909
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
14910 {
14911 2199 enemy::draw(dest);
14912 2199 return;
14913 }
14914
14915 154719 int32_t f=clk/17;
14916
14917
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
14918 {
14919 // body
14920 120524 xofs=-8;
14921 120524 yofs=32;
14922
14923
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
14924
14925 {
14926 case 0:
14927 9155 tile+=0;
14928 9155 break;
14929
14930 case 1:
14931 10095 tile+=2;
14932 10095 break;
14933
14934 case 2:
14935 8686 tile+=4;
14936 8686 break;
14937
14938 default:
14939 92588 tile+=6;
14940 92588 break;
14941 }
14942 120524 }
14943 else
14944 {
14945 // body
14946 34195 xofs=-8;
14947 34195 yofs=32;
14948
14949
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
14950 {
14951 case 0:
14952 2514 tile+=0;
14953 2514 break;
14954
14955 case 2:
14956 2459 tile+=4;
14957 2459 break;
14958
14959 default:
14960 29222 tile+=2;
14961 29222 break;
14962 }
14963 }
14964
14965 154719 enemy::drawblock(dest,15);
14966 156918 }
14967
14968 156918 void eGleeok::draw2(BITMAP *dest)
14969 {
14970 // the neck stub
14971 156918 tile=necktile;
14972 156918 xofs=0;
14973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14974
14975
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
14976 {
14977 122181 tile+=((clk&24)>>3);
14978 122181 }
14979
14980
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
14981 {
14982 154719 mapscr* scr = get_scr(screen_spawned);
14983
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
14984 737 sprite::drawcloaked(dest);
14985 else
14986 153982 sprite::draw(dest);
14987 154719 }
14988 156918 }
14989
14990
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
14991 533 {
14992
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 setParent(prnt);
14993
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
14994
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
14995 // dummy_bool[0]=false;
14996 533 timer=0;
14997 /* fixing */
14998 533 hp=1000;
14999
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
15000 533 item_set=0;
15001
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
15002
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
15003 533 hxofs=4;
15004 533 hit_width=8;
15005
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15006 533 clk2=clk; // how int32_t to wait before moving first time
15007 533 clk=0;
15008 533 mainguy=count_enemy=false;
15009
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
15010 533 clk3=((dir&2)>>1)+2; // left or right
15011 533 dir&=1; // up or down
15012
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
15013 533 isCore = false;
15014
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15015
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15016 {
15017 2132 nxoffset[i] = 0;
15018 2132 nyoffset[i] = 0;
15019
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15020
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15021 2132 }
15022
15023 533 necktile=0;
15024 //TODO compatibility? -DD
15025 /*
15026 for(int32_t i=0; i<4; i++)
15027 {
15028 nx[i]=124;
15029 ny[i]=i*6+48;
15030 }*/
15031 533 bgsfx=-1;
15032 //no need for deadsfx
15033 533 }
15034
15035 515535 bool esGleeok::animate(int32_t index)
15036 {
15037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15038 // don't call removearmos() - it's a segment.
15039
15040 515535 dmisc5=vbound(dmisc5,1,255);
15041
15042
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15043 {
15044 402762 x = (xoffset+parent->x);
15045 402762 y = (yoffset+parent->y);
15046
15047
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15048 {
15049 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15050 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15051 1611048 }
15052 402762 }
15053
15054 // set up the head tiles
15055 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15056 /*
15057 if (dummy_bool[0]) //if this is a flame gleeok
15058 {
15059 headtile+=180;
15060 }
15061 */
15062 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15063 515535 flyingheadtile=dummy_int[3];
15064
15065 // set up the neck tiles
15066 515535 necktile=dummy_int[1];
15067
15068
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15069 {
15070 402833 necktile+=((clk&24)>>3);
15071 402833 }
15072
15073 /*
15074 else
15075 {
15076 necktile=145;
15077 }
15078 */
15079 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15080
15081
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15082 {
15083 case 0: // live head
15084 // set up the attached head tiles
15085 402762 tile=headtile;
15086
15087
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15088 {
15089 319820 tile+=((clk&24)>>3);
15090 /*
15091 if (dummy_bool[0]) {
15092 tile+=1561;
15093 }
15094 */
15095 319820 }
15096
15097 /*
15098 else
15099 {
15100 tile=146;
15101 }
15102 */
15103
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15104 {
15105
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15106
15107
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15108
15109
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15110 {
15111 292 dir^=1;
15112 292 }
15113
15114 92832 zfix tempx = x;
15115 92832 zfix tempy = y;
15116
15117 92832 sprite::move(step);
15118 92832 xoffset += (x-tempx);
15119 92832 yoffset += (y-tempy);
15120
15121
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15122 {
15123 3863 clk3^=1;
15124 3863 clk2=-4;
15125 3863 }
15126 else
15127 {
15128
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15129 {
15130 978 clk3=right;
15131 978 }
15132
15133
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15134 {
15135 961 clk3=left;
15136 961 }
15137
15138
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15139 {
15140 3713 clk3^=1; // x jig
15141 3713 }
15142 else
15143 {
15144
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15145 {
15146 851 clk3^=1; // x switch back
15147 851 }
15148
15149 85256 clk2=-4;
15150 }
15151 }
15152
15153 92832 zc_swap(dir,clk3);
15154 92832 tempx = x;
15155 92832 tempy = y;
15156 92832 sprite::move(step);
15157 92832 xoffset += (x-tempx);
15158 92832 yoffset += (y-tempy);
15159 92832 zc_swap(dir,clk3);
15160
15161
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15162 {
15163 278496 nxoffset[i] = (zc_oldrand()%3);
15164 278496 nyoffset[i] = (zc_oldrand()%3);
15165 278496 }
15166 92832 }
15167
15168 402762 break;
15169
15170 case 1: // flying head
15171
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15172
15173 {
15174 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15175 105482 }
15176
15177 112071 break;
15178
15179 // the following are messages sent from the main guy...
15180 case -1: // got chopped off
15181 {
15182 300 misc=1;
15183 300 superman=1;
15184 300 hxofs=xofs=0;
15185 300 hit_width=16;
15186 300 cs=8;
15187 300 clk=-24;
15188 300 clk2=40;
15189 300 dir=(zc_oldrand()&7)+8;
15190 300 step=8.0/9.0;
15191 }
15192 300 break;
15193
15194 case -2: // the big guy is dead
15195 402 return true;
15196 }
15197
15198
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15199 {
15200
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15201 {
15202 4791 FireBreath(true);
15203 4791 }
15204
15205 40125 --timer;
15206 40125 }
15207
15208 515133 return enemy::animate(index);
15209 515535 }
15210
15211 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15212 {
15213
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15214 {
15215 int32_t wpnId = w->id;
15216
15217 if(dying)
15218 return 0;
15219
15220 switch(wpnId)
15221 {
15222 case wLitBomb:
15223 case wLitSBomb:
15224 case wBait:
15225 case wWhistle:
15226 case wFire:
15227 case wWind:
15228 case wSSparkle:
15229 case wFSparkle:
15230 case wPhantom:
15231 return 0;
15232
15233 case wHookshot:
15234 case wBrang:
15235 case wBeam:
15236 case wArrow:
15237 case wMagic:
15238 case wBomb:
15239 case wSBomb:
15240 sfx(WAV_CHINK,pan(int32_t(x)));
15241 break;
15242 default:
15243 break;
15244 }
15245
15246 return 1;
15247 }
15248 else
15249 {
15250 7080 int32_t ret = enemy::takehit(w,realweap);
15251
15252
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15253 5655 return -2; // force it to wait a frame before checking sword attacks again
15254
15255 1425 return ret;
15256 }
15257 7080 }
15258
15259 521456 void esGleeok::draw(BITMAP *dest)
15260 {
15261 521456 dmisc5=vbound(dmisc5,1,255);
15262
15263
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15264 {
15265 case 0: //neck
15266
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15267 {
15268
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15269 {
15270 1227318 mapscr* scr = get_scr(screen_spawned);
15271
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15272 {
15273
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15274 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15275 else
15276 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15277 978198 }
15278 else
15279 {
15280
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15281 overtilecloaked16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15282 else
15283 249120 overtile16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15284 }
15285 1227318 }
15286 409106 }
15287
15288 409106 break;
15289
15290 case 1: //flying head
15291 112350 tile=flyingheadtile;
15292
15293
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15294 {
15295 82692 tile+=((clk&24)>>3);
15296 82692 break;
15297 }
15298 29658 }
15299 521456 }
15300
15301 521456 void esGleeok::draw2(BITMAP *dest)
15302 {
15303 521456 enemy::draw(dest);
15304 521456 }
15305
15306 189 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15307 189 {
15308
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if ( !(editorflags & ENEMY_FLAG5) )
15309 {
15310
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 x = 128;
15311
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 y = 48;
15312 189 }
15313 else { x = X; y = Y; }
15314 189 adjusted=false;
15315
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 dir=(zc_oldrand()&7)+8;
15316 //step=0.25;
15317 189 flycnt=dmisc1;
15318 189 flycnt2=dmisc2;
15319 189 loopcnt=0;
15320 189 clk4 = 0;
15321 189 clk5 = 0;
15322 189 clk6 = 0;
15323 189 clk7 = 0;
15324
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (dmisc29 == 0)
15326 {
15327
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 105 times.
189 if(!dmisc4)
15328 {
15329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15330 105 else dmisc29 = (84 / 3);
15331 105 }
15332 else
15333 {
15334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if (dmisc10) dmisc29 = (90 / 2);
15335 84 else dmisc29 = (84 / 2);
15336 }
15337 189 }
15338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (dmisc30 == 0)
15339 {
15340
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 105 times.
189 if(!dmisc4)
15341 {
15342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15343 105 else dmisc30 = (84 / 3)*0.5;
15344 105 }
15345 else
15346 {
15347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15348 84 else dmisc30 = (84 / 2)*0.5;
15349 }
15350 189 }
15351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (dmisc31 == 0)
15352 {
15353
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 105 times.
189 if(!dmisc4)
15354 {
15355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15356 105 else dmisc31 = (84 / 3)*2;
15357 105 }
15358 else
15359 {
15360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15361 84 else dmisc31 = (84 / 2)*0.5;
15362 }
15363 189 }
15364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (dmisc32 == 0)
15365 {
15366
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 105 times.
189 if(!dmisc4)
15367 {
15368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15369 105 else dmisc32 = (84 / 3);
15370 105 }
15371 else
15372 {
15373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15374 84 else dmisc32 = (84 / 2)*0.25;
15375 }
15376 189 }
15377
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 init_size_flags();
15378 189 }
15379
15380 161847 bool ePatra::animate(int32_t index)
15381 {
15382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161847 times.
161847 if(switch_hooked) return enemy::animate(index);
15383
2/2
✓ Branch 0 taken 1426 times.
✓ Branch 1 taken 160421 times.
161847 if(dying)
15384 {
15385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1426 times.
1426 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15386 {
15387 auto segment = (enemy*)guys.spr(i);
15388 if (segment && segment->parent == this)
15389 segment->hp = -1000;
15390 }
15391
15392 1426 return Dead(index);
15393 }
15394
15395 160421 double basesize = 84;
15396
1/2
✓ Branch 0 taken 160421 times.
✗ Branch 1 not taken.
160421 if (dmisc10) basesize = 90;
15397 160421 double halfsize = basesize / 2;
15398 160421 double quartersize = halfsize / 2;
15399 160421 double twothirdsize = (basesize / 3)*2;
15400 160421 double onethirdsize = (basesize / 3);
15401
15402
15403
2/2
✓ Branch 0 taken 123488 times.
✓ Branch 1 taken 36933 times.
160421 if(clk==0)
15404 {
15405 36933 removearmos(x,y,ffcactivated);
15406 36933 }
15407
15408
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160421 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160421 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160421 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15409 {
15410
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160421 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15411
1/2
✓ Branch 0 taken 160421 times.
✗ Branch 1 not taken.
160421 if (loopcnt < 0) ++clk2;
15412
2/2
✓ Branch 0 taken 158624 times.
✓ Branch 1 taken 1797 times.
160421 if(++clk2>basesize)
15413 {
15414 1797 clk2=0;
15415
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15416 {
15417
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15418 932 --loopcnt;
15419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15420 {
15421
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if (zc::math::SafeMod(misc, dmisc6) == 0)
15422 {
15423
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15424 356 else loopcnt=dmisc7;
15425 356 }
15426 865 }
15427 else if (loopcnt == -1) loopcnt=dmisc7;
15428 else ++loopcnt;
15429
15430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15431 1797 }
15432 else
15433 {
15434 loopcnt = 0;
15435 misc = 1;
15436 }
15437 1797 }
15438 160421 }
15439
1/2
✓ Branch 0 taken 160421 times.
✗ Branch 1 not taken.
160421 if (clk4 > 0) --clk4;
15440
15441
1/2
✓ Branch 0 taken 160421 times.
✗ Branch 1 not taken.
160421 if (clk6 < 0)
15442 {
15443 if (dmisc5 == 1 || dmisc5 == 3)
15444 {
15445 if (get_qr(qr_NEWENEMYTILES))
15446 {
15447 if (clk7 <= 0 || clk6 != -16) ++clk6;
15448 if (clk6 == 0) o_tile=d->e_tile;
15449 else
15450 {
15451 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15452 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15453 }
15454 }
15455 else clk6 = 0;
15456 }
15457 }
15458
1/2
✓ Branch 0 taken 160421 times.
✗ Branch 1 not taken.
160421 else if (dmisc19) ++clk6;
15459
1/2
✓ Branch 0 taken 160421 times.
✗ Branch 1 not taken.
160421 if (clk5 < 0) ++clk5;
15460
1/2
✓ Branch 0 taken 160421 times.
✗ Branch 1 not taken.
160421 else if (dmisc19) ++clk5;
15461
15462
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160421 if (clk7 > 0 && clk6 >= -16) --clk7;
15463
1/2
✓ Branch 0 taken 160421 times.
✗ Branch 1 not taken.
160421 if (clk6 > 0) clk7 = 0;
15464
15465
2/2
✓ Branch 0 taken 660228 times.
✓ Branch 1 taken 160421 times.
820649 for(int32_t i=index+1; i<index+flycnt+1; i++)
15466 {
15467 //outside ring
15468
2/2
✓ Branch 0 taken 658892 times.
✓ Branch 1 taken 1336 times.
660228 if(!adjusted)
15469 {
15470
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 184 times.
1336 if(get_qr(qr_NEWENEMYTILES))
15471 {
15472 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15473 1152 enemy *s = ((enemy*)guys.spr(i));
15474 1152 s->setParent(this);
15475 1152 }
15476 else
15477 {
15478 184 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15479 184 enemy *s = ((enemy*)guys.spr(i));
15480 184 s->setParent(this);
15481 }
15482
15483 1336 ((enemy*)guys.spr(i))->cs=dmisc9;
15484 1336 ((enemy*)guys.spr(i))->hp=dmisc3;
15485 1336 }
15486
15487
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 659468 times.
660228 if(((enemy*)guys.spr(i))->hp <= 0)
15488 {
15489
2/2
✓ Branch 0 taken 2873 times.
✓ Branch 1 taken 760 times.
3633 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15490 {
15491 2873 guys.swap(j,j+1);
15492 2873 }
15493
15494
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 666 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
760 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15495 760 }
15496 else
15497 {
15498 659468 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15499
1/2
✓ Branch 0 taken 659468 times.
✗ Branch 1 not taken.
659468 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15500
15501
2/2
✓ Branch 0 taken 211885 times.
✓ Branch 1 taken 447583 times.
659468 if(!dmisc4) //Big Ring
15502 {
15503 //maybe playing_field_offset here?
15504
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15505 {
15506
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15507
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15508 237330 }
15509 else
15510 {
15511 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15512 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15513 }
15514
15515 447583 temp_x=guys.spr(i)->x;
15516 447583 temp_y=guys.spr(i)->y;
15517 447583 }
15518 else //Oval
15519 {
15520 211885 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15521 211885 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15522
15523
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90844 times.
211885 if(loopcnt>0)
15524 {
15525 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15526
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15527 121041 }
15528 else
15529 {
15530 90844 guys.spr(i)->x = circle_x;
15531 90844 guys.spr(i)->y = circle_y;
15532 }
15533
15534 211885 temp_x=circle_x;
15535 211885 temp_y=circle_y;
15536 }
15537
15538 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15539 659468 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15540
15541
4/4
✓ Branch 0 taken 123980 times.
✓ Branch 1 taken 535488 times.
✓ Branch 2 taken 40882 times.
✓ Branch 3 taken 83098 times.
659468 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15542 {
15543 83098 guys.spr(i)->dir=l_down;
15544 83098 }
15545
4/4
✓ Branch 0 taken 124431 times.
✓ Branch 1 taken 451939 times.
✓ Branch 2 taken 40882 times.
✓ Branch 3 taken 83549 times.
576370 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15546 {
15547 83549 guys.spr(i)->dir=left;
15548 83549 }
15549
4/4
✓ Branch 0 taken 123317 times.
✓ Branch 1 taken 369504 times.
✓ Branch 2 taken 40882 times.
✓ Branch 3 taken 82435 times.
492821 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15550 {
15551 82435 guys.spr(i)->dir=l_up;
15552 82435 }
15553
4/4
✓ Branch 0 taken 123051 times.
✓ Branch 1 taken 287335 times.
✓ Branch 2 taken 40882 times.
✓ Branch 3 taken 82169 times.
410386 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15554 {
15555 82169 guys.spr(i)->dir=up;
15556 82169 }
15557
4/4
✓ Branch 0 taken 122463 times.
✓ Branch 1 taken 205754 times.
✓ Branch 2 taken 40882 times.
✓ Branch 3 taken 81581 times.
328217 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15558 {
15559 81581 guys.spr(i)->dir=r_up;
15560 81581 }
15561
4/4
✓ Branch 0 taken 122856 times.
✓ Branch 1 taken 123780 times.
✓ Branch 2 taken 40882 times.
✓ Branch 3 taken 81974 times.
246636 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15562 {
15563 81974 guys.spr(i)->dir=right;
15564 81974 }
15565
4/4
✓ Branch 0 taken 122562 times.
✓ Branch 1 taken 42100 times.
✓ Branch 2 taken 40882 times.
✓ Branch 3 taken 81680 times.
164662 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15566 {
15567 81680 guys.spr(i)->dir=r_down;
15568 81680 }
15569 else
15570 {
15571 82982 guys.spr(i)->dir=down;
15572 }
15573
15574 659468 guys.spr(i)->x += x;
15575 659468 guys.spr(i)->y += y;
15576 }
15577 660228 }
15578
15579
7/22
✓ Branch 0 taken 106937 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106937 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160421 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15580 {
15581 32331 int timeneeded = 48;
15582 32331 int patbreath = (zc_oldrand()%50+50);
15583
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15584
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15585 {
15586 timeneeded = 48 + patbreath;
15587 }
15588
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15589 {
15590 timeneeded = 48 + 96;
15591 }
15592
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15593
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15594
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15595 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15596 249 && (clk6 >= 0) //if not in the middle of firing...
15597 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15598
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15599 {
15600
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15601 {
15602 case patratSTREAM:
15603 {
15604 clk7 = 97;
15605 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15606 else clk6 = 0;
15607 break;
15608 }
15609 case patratBREATH:
15610 {
15611 clk7 = patbreath;
15612 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15613 else clk6 = 0;
15614 break;
15615 }
15616 default:
15617 {
15618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15619 {
15620 clk6 = -48;
15621 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15622 }
15623 else
15624 {
15625 249 clk6 = 0;
15626
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15627 249 FirePatraWeapon();
15628 }
15629 249 break;
15630 }
15631 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15632 249 }
15633
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15634 {
15635 switch(dmisc28)
15636 {
15637 case patratSTREAM:
15638 {
15639 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15640 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15641 break;
15642 }
15643 case patratBREATH:
15644 {
15645 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15646 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15647 break;
15648 }
15649 default:
15650 {
15651 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15652 {
15653 FirePatraWeapon();
15654 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15655 }
15656 break;
15657 }
15658 }
15659 }
15660 32331 }
15661
15662 160421 int randattempts = 0;
15663 160421 int randeye = 0;
15664
2/2
✓ Branch 0 taken 114181 times.
✓ Branch 1 taken 46240 times.
160421 if (flycnt2 > 0)
15665 {
15666 46240 do
15667 {
15668
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15669 46240 randeye += (index + flycnt + 1);
15670 46240 ++randattempts;
15671
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15672 46240 }
15673 160421 bool dofire = false;
15674
1/2
✓ Branch 0 taken 160421 times.
✗ Branch 1 not taken.
160421 if (dmisc20)
15675 {
15676 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15677 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15678 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15679 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15680 || (((((zc::math::SafeMod(misc, dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15681 {
15682 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15683 {
15684 if (clk5 >= dmisc19)
15685 {
15686 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15687 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15688 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + 96)) ||
15689 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48)))
15690 || dmisc18 == -1)
15691 dofire = true;
15692 }
15693 }
15694 }
15695 }
15696
2/2
✓ Branch 0 taken 114181 times.
✓ Branch 1 taken 46240 times.
160421 if(flycnt2)
15697 {
15698
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15699 {
15700
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15701 {
15702 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15703
15704
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
15705 {
15706
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15707 {
15708
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
15709 {
15710 // Center eye shoots projectiles; make room for its firing tiles
15711 case 1:
15712 case 3:
15713 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
15714 144 break;
15715
15716 // Center eyes does not shoot; use tiles two rows below for inner eyes.
15717 default:
15718 case 2:
15719 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
15720 168 break;
15721 }
15722 312 }
15723 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
15724 312 }
15725 else
15726 {
15727 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15728 }
15729
15730 312 ((enemy*)guys.spr(i))->cs=dmisc9;
15731
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
15732 312 }
15733
15734
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
15735 {
15736 263816 ((enemy*)guys.spr(i))->superman=true;
15737 263816 }
15738 else
15739 {
15740 70613 ((enemy*)guys.spr(i))->superman=false;
15741 }
15742
15743
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
15744 {
15745
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15746 {
15747 269 guys.swap(j,j+1);
15748 269 }
15749
15750
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
15751 145 }
15752 else
15753 {
15754 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15755
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
15756
15757
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
15758 {
15759
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
15760 {
15761
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15762
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15763 168378 }
15764 else
15765 {
15766 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15767 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15768 }
15769
15770 327025 temp_x=guys.spr(i)->x;
15771 327025 temp_y=guys.spr(i)->y;
15772 327025 }
15773 else
15774 {
15775 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15776 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15777
15778
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
15779 {
15780 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15781
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
15782 3965 }
15783 else
15784 {
15785 3294 guys.spr(i)->x = circle_x;
15786 3294 guys.spr(i)->y = circle_y;
15787 }
15788
15789 7259 temp_x=circle_x;
15790 7259 temp_y=circle_y;
15791 }
15792
15793 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15794 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15795
15796
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15797 {
15798 41746 guys.spr(i)->dir=l_down;
15799 41746 }
15800
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15801 {
15802 41734 guys.spr(i)->dir=left;
15803 41734 }
15804
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15805 {
15806 41742 guys.spr(i)->dir=l_up;
15807 41742 }
15808
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15809 {
15810 41758 guys.spr(i)->dir=up;
15811 41758 }
15812
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15813 {
15814 41830 guys.spr(i)->dir=r_up;
15815 41830 }
15816
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15817 {
15818 41824 guys.spr(i)->dir=right;
15819 41824 }
15820
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15821 {
15822 41852 guys.spr(i)->dir=r_down;
15823 41852 }
15824 else
15825 {
15826 41798 guys.spr(i)->dir=down;
15827 }
15828
15829 334284 guys.spr(i)->x += x;
15830 334284 guys.spr(i)->y = y-guys.spr(i)->y;
15831
15832
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
15833 {
15834 /*
15835 if(!(zc_oldrand()&127))
15836 {
15837 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
15838 sfx(wpnsfx(wpn),pan(int32_t(x)));
15839 }
15840 */
15841
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
15842 {
15843 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
15844 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15845 {
15846 if (dmisc5 == 3)
15847 {
15848 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15849 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
15850 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
15851 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15852 }
15853 else
15854 {
15855 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15856 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15857 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
15858 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15859 }
15860 }
15861 else
15862 {
15863 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15864 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
15865 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
15866 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15867 }
15868 }
15869
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
15870
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
15871
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
15872 {
15873
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
15874 {
15875 case 4: //Single one rapidfires
15876 {
15877 if (dofire && i == randeye)
15878 {
15879 ((esPatra*)guys.spr(i))->clk5 = -16;
15880 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
15881 ((esPatra*)guys.spr(i))->clk4 = 96;
15882 clk5 = -3;
15883 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15884 }
15885 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
15886 {
15887 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15888 sfx(wpnsfx(wpn),pan(int32_t(x)));
15889 }
15890 break;
15891 }
15892 case 3: //Ring
15893 {
15894 if (dofire)
15895 {
15896 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15897 {
15898 ((esPatra*)guys.spr(i))->clk5 = -48;
15899 clk5 = -48;
15900 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15901 }
15902 else
15903 {
15904 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15905 sfx(wpnsfx(wpn),pan(int32_t(x)));
15906 int32_t m=Ewpns.Count()-1;
15907 weapon *ew = (weapon*)(Ewpns.spr(m));
15908
15909 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15910 ((esPatra*)guys.spr(i))->clk5 = 0;
15911 clk5 = 0;
15912 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15913 }
15914 }
15915 if (((esPatra*)guys.spr(i))->clk5 == -16)
15916 {
15917 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15918 sfx(wpnsfx(wpn),pan(int32_t(x)));
15919 int32_t m=Ewpns.Count()-1;
15920 weapon *ew = (weapon*)(Ewpns.spr(m));
15921
15922 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15923 }
15924 break;
15925 }
15926 case 2: //one after another
15927 {
15928 if (dofire)
15929 {
15930 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
15931 clk5 = -48 - (12*flycnt2);
15932 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15933 }
15934 if (((esPatra*)guys.spr(i))->clk5 == -16)
15935 {
15936 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15937 sfx(wpnsfx(wpn),pan(int32_t(x)));
15938 }
15939 break;
15940 }
15941 case 1: //random one eye
15942 {
15943 if (dofire && i == randeye)
15944 {
15945 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15946 {
15947 ((esPatra*)guys.spr(i))->clk5 = -48;
15948 clk5 = -48;
15949 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15950 }
15951 else
15952 {
15953 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15954 sfx(wpnsfx(wpn),pan(int32_t(x)));
15955 ((esPatra*)guys.spr(i))->clk5 = 0;
15956 clk5 = 0;
15957 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15958 }
15959 }
15960 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15961 {
15962 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15963 sfx(wpnsfx(wpn),pan(int32_t(x)));
15964 }
15965 break;
15966 }
15967 default: //old behavior, all eyes can fire any time
15968 {
15969
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15970
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15971
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15972 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48))))
15973 {
15974
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15975 {
15976 ((esPatra*)guys.spr(i))->clk5 = -48;
15977 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15978 }
15979 else
15980 {
15981 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15982 1155 sfx(wpnsfx(wpn),pan(int32_t(x)));
15983 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
15984
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15985 }
15986 1155 }
15987
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15988 {
15989 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15990 sfx(wpnsfx(wpn),pan(int32_t(x)));
15991 }
15992 145268 break;
15993 }
15994 }
15995 145268 }
15996 145268 }
15997
15998 }
15999 334429 }
16000 46240 }
16001
16002 160421 adjusted=true;
16003 160421 return enemy::animate(index);
16004 161847 }
16005
16006 249 void ePatra::FirePatraWeapon()
16007 { //.707
16008 249 int32_t xoff = 0;
16009 249 int32_t yoff = 0;
16010
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
16011 {
16012 xoff += hxofs;
16013 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
16014 xoff += (hit_width / 2) - (weap_data.tilew * 8);
16015 else
16016 xoff += (hit_width / 2) - 8;
16017 }
16018
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
16019 {
16020 yoff += hyofs;
16021 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
16022 yoff += (hit_height / 2) - (weap_data.tileh * 8);
16023 else
16024 yoff += (hit_height / 2) - 8;
16025 }
16026 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16027 // TODO(crash): check that .add succeeds.
16028
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16029 {
16030 case patrat8SHOT: //Fire Wizzrobe
16031 case patrat4SHOTDIAG:
16032 case patrat4SHOTRAND:
16033 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16034 {
16035 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16036 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16037 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16038 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16039
16040 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16041 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16042 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16043 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16044
16045 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16046 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16047 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16048 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16049
16050 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16051 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16052 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16053 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16054
16055 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16056 }
16057
16058 [[fallthrough]];
16059 case patrat4SHOTCARD: //Stalfos 3
16060 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16061 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16062 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16063 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16064 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16065 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16066 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16067 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16068 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16069 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16070 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16071 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16072 break;
16073
16074 default:
16075 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16076
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16077 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16078
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16079
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16080 {
16081 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16082 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16083 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16084 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16085 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16086 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16087 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16088 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16089 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16090 {
16091 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16092 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16093 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16094 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16095 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16096 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16097 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16098 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16099 }
16100 }
16101 249 break;
16102
16103 }
16104 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16105 //+0.46364761
16106 //11.80
16107 249 }
16108
16109 324166 void ePatra::draw(BITMAP *dest)
16110 {
16111 324166 tile=o_tile;
16112 324166 update_enemy_frame();
16113 324166 enemy::draw(dest);
16114 324166 }
16115
16116 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16117 {
16118 int32_t ret = enemy::defend(wpnId, power, edef);
16119
16120 if(ret < 0 && (flycnt||flycnt2))
16121 return 0;
16122
16123 return ret;
16124 }
16125
16126 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16127 {
16128 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16129
16130
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16131 1281 return 0;
16132
16133 452 return ret;
16134 1733 }
16135
16136 189 void ePatra::init_size_flags() {
16137 189 SIZEflags = d->SIZEflags;
16138
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
189 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16139
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16140 // al_trace("Enemy txsz:%i\n", txsz);
16141
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
189 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16142
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16144
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) hit_width = 32;
16145
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16146
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16148
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) hxofs = -8;
16149
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16150 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16152
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) xofs = -8;
16153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16154 {
16155 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16156 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16157 }
16158
1/4
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16159
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if (editorflags & ENEMY_FLAG8) misc = 1;
16160
16161
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16162
16163 189 }
16164
16165 1648 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16166 1648 {
16167 //cs=8;
16168
1/2
✓ Branch 0 taken 1648 times.
✗ Branch 1 not taken.
1648 setParent(prnt);
16169 1648 item_set=0;
16170 1648 misc=clk;
16171 1648 clk4 = 0;
16172 1648 clk5 = 0;
16173 1648 clk = -((misc*21)>>1)-1;
16174
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1648 times.
✓ Branch 2 taken 1648 times.
✗ Branch 3 not taken.
1648 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16175 1648 hit_width=12;
16176 1648 hit_height=12;
16177 1648 hxofs=2;
16178 1648 hyofs=2;
16179 1648 extend = 0;
16180 1648 txsz = 1;
16181 1648 tysz = 1;
16182 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16183 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16184 int32_t prntSIZEflags = prntenemy->SIZEflags;
16185 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16186 // al_trace("Enemy txsz:%i\n", txsz);
16187 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16188 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16189 else
16190 hxsz=12;
16191 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16192 else
16193 hysz=12;
16194 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16195 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16196 else
16197 hxofs=2;
16198 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16199 else hyofs=2;
16200 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16201 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16202 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16203 {
16204 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16205 }
16206
16207 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16208 */
16209 1648 mainguy=count_enemy=false;
16210 1648 bgsfx=-1;
16211 //o_tile=0;
16212
2/4
✓ Branch 0 taken 1648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1648 times.
✗ Branch 3 not taken.
1648 flags &= (~guy_never_return);
16213 1648 deadsfx = WAV_EDEAD;
16214 1648 hitsfx = WAV_EHIT;
16215 1648 isCore = false;
16216 1648 }
16217
16218 1010280 bool esPatra::animate(int32_t index)
16219 {
16220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010280 times.
1010280 if(switch_hooked) return enemy::animate(index);
16221
2/2
✓ Branch 0 taken 15016 times.
✓ Branch 1 taken 995264 times.
1010280 if(dying)
16222 15016 return Dead(index);
16223
16224 995264 return enemy::animate(index);
16225 1010280 }
16226
16227 2027588 void esPatra::draw(BITMAP *dest)
16228 {
16229
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306294 times.
2027588 if(get_qr(qr_NEWENEMYTILES))
16230 {
16231 1721294 tile = o_tile+(clk&3);
16232
16233
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16234 {
16235 case up: //u
16236 214278 flip=0;
16237 214278 break;
16238
16239 case down: //d
16240 217924 flip=0;
16241 217924 tile+=4;
16242 217924 break;
16243
16244 case left: //l
16245 215346 flip=0;
16246 215346 tile+=8;
16247 215346 break;
16248
16249 case right: //r
16250 215726 flip=0;
16251 215726 tile+=12;
16252 215726 break;
16253
16254 case l_up: //ul
16255 213062 flip=0;
16256 213062 tile+=20;
16257 213062 break;
16258
16259 case r_up: //ur
16260 214350 flip=0;
16261 214350 tile+=24;
16262 214350 break;
16263
16264 case l_down: //dl
16265 215734 flip=0;
16266 215734 tile+=28;
16267 215734 break;
16268
16269 case r_down: //dr
16270 214874 flip=0;
16271 214874 tile+=32;
16272 214874 break;
16273 }
16274 1721294 }
16275 else
16276 {
16277 306294 tile = o_tile+((clk&2)>>1);
16278 }
16279
16280
2/2
✓ Branch 0 taken 114376 times.
✓ Branch 1 taken 1913212 times.
2027588 if(clk>=0)
16281 1913212 enemy::draw(dest);
16282 2027588 }
16283
16284
16285 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16286 102 {
16287 102 adjusted=false;
16288
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16289
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16290 102 clk4 = 0;
16291 102 clk5 = 0;
16292 //flycnt=6; flycnt2=0;
16293 102 flycnt=dmisc1;
16294 102 flycnt2=0; // PatraBS doesn't have inner rings!
16295 102 loopcnt=0;
16296
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16298
16299 //nets+4480;
16300 102 }
16301
16302 35963 bool ePatraBS::animate(int32_t index)
16303 {
16304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16305
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16306 240 return Dead(index);
16307
16308
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16309 {
16310 4018 removearmos(x,y,ffcactivated);
16311 4018 }
16312
16313 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16314
16315
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16316 {
16317 336 clk2=0;
16318
16319
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16320 177 --loopcnt;
16321 else
16322 {
16323
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if(zc::math::SafeMod(misc, dmisc6)==0)
16324 84 loopcnt=dmisc7;
16325 }
16326
16327 336 ++misc;
16328 336 }
16329
16330 // double size=1;;
16331
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16332 {
16333
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16334 {
16335 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16336
16337
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16338 {
16339 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16340 612 }
16341 else
16342 {
16343 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16344 }
16345
16346 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16347 612 }
16348
16349
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16350 {
16351
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16352 {
16353 131 guys.swap(j,j+1);
16354 131 }
16355
16356 104 --flycnt;
16357 104 }
16358 else
16359 {
16360 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16361
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16362 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16363 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16364
16365
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16366 {
16367 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16368
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16369 77643 }
16370 else
16371 {
16372 75725 guys.spr(i)->x = temp_x;
16373 75725 guys.spr(i)->y = temp_y;
16374 }
16375
16376 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16377 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16378
16379
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16380 {
16381 18812 guys.spr(i)->dir=l_down;
16382 18812 }
16383
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16384 {
16385 18839 guys.spr(i)->dir=left;
16386 18839 }
16387
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16388 {
16389 18802 guys.spr(i)->dir=l_up;
16390 18802 }
16391
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16392 {
16393 20143 guys.spr(i)->dir=up;
16394 20143 }
16395
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16396 {
16397 18517 guys.spr(i)->dir=r_up;
16398 18517 }
16399
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16400 {
16401 18779 guys.spr(i)->dir=right;
16402 18779 }
16403
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16404 {
16405 18992 guys.spr(i)->dir=r_down;
16406 18992 }
16407 else
16408 {
16409 20484 guys.spr(i)->dir=down;
16410 }
16411
16412 153368 guys.spr(i)->x += x;
16413 153368 guys.spr(i)->y += y;
16414 }
16415 153472 }
16416
16417 35723 adjusted=true;
16418 35723 return enemy::animate(index);
16419 35963 }
16420
16421 72874 void ePatraBS::draw(BITMAP *dest)
16422 {
16423 72874 tile=o_tile;
16424
16425
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16426 {
16427 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16428 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16429
16430
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16431 {
16432 19146 lookat=l_down;
16433 19146 }
16434
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16435 {
16436 18298 lookat=down;
16437 18298 }
16438
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16439 {
16440 13624 lookat=r_down;
16441 13624 }
16442
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16443 {
16444 7492 lookat=right;
16445 7492 }
16446
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16447 {
16448 1170 lookat=r_up;
16449 1170 }
16450
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16451 {
16452 964 lookat=up;
16453 964 }
16454
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16455 {
16456 1700 lookat=l_up;
16457 1700 }
16458 else
16459 {
16460 10480 lookat=left;
16461 }
16462
16463
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16464 {
16465 case up: //u
16466 964 flip=0;
16467 964 break;
16468
16469 case down: //d
16470 18298 flip=0;
16471 18298 tile+=8;
16472 18298 break;
16473
16474 case left: //l
16475 10480 flip=0;
16476 10480 tile+=40;
16477 10480 break;
16478
16479 case right: //r
16480 7492 flip=0;
16481 7492 tile+=48;
16482 7492 break;
16483
16484 case l_up: //ul
16485 1700 flip=0;
16486 1700 tile+=80;
16487 1700 break;
16488
16489 case r_up: //ur
16490 1170 flip=0;
16491 1170 tile+=88;
16492 1170 break;
16493
16494 case l_down: //dl
16495 19146 flip=0;
16496 19146 tile+=120;
16497 19146 break;
16498
16499 case r_down: //dr
16500 13624 flip=0;
16501 13624 tile+=128;
16502 13624 break;
16503 }
16504
16505 72874 tile+=(2*(clk&3));
16506 72874 xofs-=8;
16507 72874 yofs-=8;
16508 72874 drawblock(dest,15);
16509 72874 xofs+=8;
16510 72874 yofs+=8;
16511 72874 }
16512 else
16513 {
16514 flip=(clk&1);
16515 xofs-=8;
16516 yofs-=8;
16517 enemy::draw(dest);
16518 xofs+=16;
16519 enemy::draw(dest);
16520 yofs+=16;
16521 enemy::draw(dest);
16522 xofs-=16;
16523 enemy::draw(dest);
16524 xofs+=8;
16525 yofs-=8;
16526 }
16527 72874 }
16528
16529 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16530 {
16531 int32_t ret = enemy::defend(wpnId, power, edef);
16532
16533 if(ret < 0 && (flycnt||flycnt2))
16534 return 0;
16535
16536 return ret;
16537 }
16538
16539 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16540 {
16541 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16542
16543
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16544 81 return 0;
16545
16546 61 return ret;
16547 142 }
16548
16549 102 void ePatraBS::init_size_flags()
16550 {
16551 102 SIZEflags = d->SIZEflags;
16552
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16553 // al_trace("Enemy txsz:%i\n", txsz);
16554
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16555
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16556 102 else hit_width = 32;
16557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16560 102 else hxofs = -8;
16561
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16562 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16563
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16564
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16565 {
16566 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16567 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16568 }
16569
16570
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16571 102 }
16572
16573 612 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16574 612 {
16575 //cs=csBOSS;
16576
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 setParent(prnt);
16577 612 item_set=0;
16578 612 misc=clk;
16579 612 clk = -((misc*21)>>1)-1;
16580 612 clk4 = 0;
16581 612 clk5 = 0;
16582
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16583 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16584
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16585 // al_trace("Enemy txsz:%i\n", txsz);
16586
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16587
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16588 612 else hit_width=16;
16589
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16590 612 else hit_height=16;
16591
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16592
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16594 612 else hyofs=2;
16595 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16596
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16598 {
16599 yofs = (int32_t)prntenemy->yofs;
16600 }
16601
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16602
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16603
16604 612 bgsfx=-1;
16605 612 mainguy=count_enemy=false;
16606 612 deadsfx = WAV_EDEAD;
16607 612 hitsfx = WAV_EHIT;
16608
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16609 612 isCore = false;
16610 612 }
16611
16612 155090 bool esPatraBS::animate(int32_t index)
16613 {
16614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16615
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16616 1552 return Dead(index);
16617
16618 153538 return enemy::animate(index);
16619 155090 }
16620
16621 315868 void esPatraBS::draw(BITMAP *dest)
16622 {
16623 315868 tile=o_tile;
16624
16625
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16626 {
16627
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16628 {
16629 case up: //u
16630 41612 flip=0;
16631 41612 break;
16632
16633 case down: //d
16634 42622 flip=0;
16635 42622 tile+=4;
16636 42622 break;
16637
16638 case left: //l
16639 37916 flip=0;
16640 37916 tile+=8;
16641 37916 break;
16642
16643 case right: //r
16644 38458 flip=0;
16645 38458 tile+=12;
16646 38458 break;
16647
16648 case l_up: //ul
16649 38564 flip=0;
16650 38564 tile+=20;
16651 38564 break;
16652
16653 case r_up: //ur
16654 38568 flip=0;
16655 38568 tile+=24;
16656 38568 break;
16657
16658 case l_down: //dl
16659 38662 flip=0;
16660 38662 tile+=28;
16661 38662 break;
16662
16663 case r_down: //dr
16664 39466 flip=0;
16665 39466 tile+=32;
16666 39466 break;
16667 }
16668
16669 315868 tile += ((clk&6)>>1);
16670 315868 }
16671 else
16672 {
16673 tile += (clk&4)?1:0;
16674 }
16675
16676
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16677 283752 enemy::draw(dest);
16678 315868 }
16679
16680 257603 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16681 {
16682
4/6
✓ Branch 0 taken 150748 times.
✓ Branch 1 taken 106855 times.
✓ Branch 2 taken 150748 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150748 times.
✗ Branch 5 not taken.
257603 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16683
4/8
✓ Branch 0 taken 257603 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 257603 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257603 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257603 times.
✗ Branch 7 not taken.
257603 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16684
1/2
✓ Branch 0 taken 257603 times.
✗ Branch 1 not taken.
257603 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16685 257603 }
16686
16687 74609 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16688 {
16689 // Kludge
16690
4/8
✓ Branch 0 taken 74609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74609 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74609 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74609 times.
✗ Branch 7 not taken.
74609 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16691 74609 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74609 times.
74609 delete w;
16693 74609 return ret;
16694 }
16695
16696 9214 void enemy_scored(int32_t index)
16697 {
16698 9214 ((enemy*)guys.spr(index))->scored=true;
16699 9214 }
16700
16701 2191 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16702 {
16703
5/8
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 279 times.
✓ Branch 5 taken 1912 times.
✓ Branch 6 taken 2191 times.
✗ Branch 7 not taken.
2191 guy *g = new guy((zfix)x,(zfix)y,id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16704
2/2
✓ Branch 0 taken 1426 times.
✓ Branch 1 taken 765 times.
2191 if (isdungeon(g->screen_spawned))
16705 765 g->y += 1;
16706
5/6
✓ Branch 0 taken 1277 times.
✓ Branch 1 taken 914 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1273 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2191 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16707 {
16708 4 g->o_tile = parentscr->guytile;
16709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16710 4 g->flags &= ~guy_invisible;
16711 4 g->cs = parentscr->guycs;
16712 4 }
16713 2191 guys.add(g);
16714 2191 }
16715
16716 23701 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16717 {
16718
4/8
✓ Branch 0 taken 23701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23701 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23701 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23701 times.
✗ Branch 7 not taken.
23701 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
16719 23701 items.add(i);
16720 23701 }
16721
16722 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
16723 {
16724
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
16725 150 items.add(i);
16726 150 }
16727
16728 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16729 {
16730
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
16731 3 items.add(i);
16732 3 }
16733
16734 19326 void add_item_for_screen(int32_t screen, item* item)
16735 {
16736 19326 item->screen_spawned = screen;
16737 19326 items.add(item);
16738 19326 }
16739
16740 96 void kill_em_all()
16741 {
16742
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
16743 {
16744 353 enemy *e = ((enemy*)guys.spr(i));
16745
16746
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
16747
16748 323 e->kickbucket();
16749 323 }
16750 96 }
16751
16752 bool can_kill_em_all()
16753 {
16754 for(int32_t i=0; i<guys.Count(); i++)
16755 {
16756 enemy *e = ((enemy*)guys.spr(i));
16757
16758 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
16759 if(e->superman) continue;
16760 return true;
16761 }
16762 return false;
16763 }
16764
16765 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
16766 // For Hero's hit detection. Don't count them if they are stunned or are guys.
16767 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16768 {
16769 for(int32_t i=0; i<guys.Count(); i++)
16770 {
16771 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16772 {
16773 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
16774 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
16775 {
16776 return i;
16777 }
16778 }
16779 }
16780
16781 return -1;
16782 }
16783
16784 13160388 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16785 {
16786
4/4
✓ Branch 0 taken 16511 times.
✓ Branch 1 taken 13143877 times.
✓ Branch 2 taken 33816432 times.
✓ Branch 3 taken 13129631 times.
46946063 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
16787 {
16788
2/2
✓ Branch 0 taken 30757 times.
✓ Branch 1 taken 33785675 times.
33816432 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16789 {
16790 30757 return i;
16791 }
16792 33785675 }
16793
16794 13129631 return -1;
16795 13160388 }
16796
16797 // For Hero's hit detection. Count them if they are dying.
16798 52504 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16799 {
16800 52504 enemy *e = (enemy*)guys.spr(index);
16801
3/4
✓ Branch 0 taken 52504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28051 times.
✓ Branch 3 taken 24453 times.
52504 if(!e || e->hp > 0)
16802 28051 return -1;
16803
16804 24453 bool d = e->dying;
16805 24453 int32_t hc = e->hclk;
16806 24453 e->dying = false;
16807 24453 e->hclk = 0;
16808 24453 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
16809 24453 e->dying = d;
16810 24453 e->hclk = hc;
16811
16812
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24296 times.
24453 return hit ? index : -1;
16813 52504 }
16814
16815 14677859 bool hasMainGuy(int screen)
16816 {
16817
2/2
✓ Branch 0 taken 15977733 times.
✓ Branch 1 taken 5955827 times.
21933560 for(int32_t i=0; i<guys.Count(); i++)
16818 {
16819 15977733 enemy* e = (enemy*)guys.spr(i);
16820
4/4
✓ Branch 0 taken 15513899 times.
✓ Branch 1 taken 463834 times.
✓ Branch 2 taken 8722032 times.
✓ Branch 3 taken 6791867 times.
15977733 if (e->screen_spawned == screen && e->mainguy)
16821 {
16822 8722032 return true;
16823 }
16824 7255701 }
16825
16826 5955827 return false;
16827 14677859 }
16828
16829 138 void EatHero(int32_t index)
16830 {
16831 138 ((eStalfos*)guys.spr(index))->eathero();
16832 138 }
16833
16834 9 void GrabHero(int32_t index)
16835 {
16836 9 ((eWallM*)guys.spr(index))->grabhero();
16837 9 }
16838
16839 1338 bool CarryHero()
16840 {
16841
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
16842 {
16843
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->family==eeWALLM)
16844 {
16845
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
16846 {
16847 1338 Hero.x=guys.spr(i)->x;
16848 1338 Hero.y=guys.spr(i)->y;
16849 1338 return ((eWallM*)guys.spr(i))->misc > 0;
16850 }
16851 505 }
16852
16853 // Like Likes currently can't carry Hero.
16854 /*
16855 if(((guy*)(guys.spr(i)))->family==eeLIKE)
16856 {
16857 if(((eLikeLike*)guys.spr(i))->hashero)
16858 {
16859 Hero.x=guys.spr(i)->x;
16860 Hero.y=guys.spr(i)->y;
16861 return (true);
16862 }
16863 }*/
16864 2595 }
16865
16866 return false;
16867 1338 }
16868
16869 // Move item with guy
16870 void movefairy(zfix &x,zfix &y,int32_t misc)
16871 {
16872 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16873
16874 if(i!=-1)
16875 {
16876 x = guys.spr(i)->x;
16877 y = guys.spr(i)->y;
16878 }
16879 }
16880
16881 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16882 void movefairy2(zfix x,zfix y,int32_t misc)
16883 {
16884 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16885
16886 if(i!=-1)
16887 {
16888 guys.spr(i)->x = x;
16889 guys.spr(i)->y = y;
16890 }
16891 }// Move item with guy
16892
16893 60788 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
16894 {
16895 60788 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16896
16897
1/2
✓ Branch 0 taken 60788 times.
✗ Branch 1 not taken.
60788 if(fairy)
16898 {
16899 60788 x = fairy->x;
16900 60788 y = fairy->y;
16901 60788 }
16902 60788 }
16903
16904 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16905 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
16906 {
16907 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16908
16909
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
16910 {
16911 404 fairy->x = x;
16912 404 fairy->y = y;
16913 404 }
16914 404 }
16915
16916 void killfairy(int32_t misc)
16917 {
16918 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16919 guys.del(i);
16920 }
16921
16922 219 int32_t getGuyIndex(const int32_t eid)
16923 {
16924
1/2
✓ Branch 0 taken 828 times.
✗ Branch 1 not taken.
828 for(word i = 0; i < guys.Count(); i++)
16925 {
16926
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 609 times.
828 if(guys.spr(i)->getUID() == eid)
16927 219 return i;
16928 609 }
16929
16930 return -1;
16931 219 }
16932
16933 219 void killfairynew(item const &itemfairy)
16934 {
16935 219 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16936
1/2
✓ Branch 0 taken 219 times.
✗ Branch 1 not taken.
219 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
16937 219 }
16938
16939 //Should probably change this to return an 'enemy*', null on failure -Em
16940 21821 int32_t addenemy(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk)
16941 {
16942 21821 return addenemy_z(screen,x,y,0,id,clk);
16943 }
16944
16945 1965 int32_t addchild(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk, sprite* parent)
16946 {
16947 1965 return addchild_z(screen,x,y,0,id,clk, parent);
16948 }
16949
16950 1997 int32_t addchild_z(int32_t screen, int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, sprite* parent)
16951 {
16952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
16953
16954 1997 int32_t ret = 0;
16955 1997 sprite *e=NULL;
16956
16957
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].family)
16958 {
16959 //Fixme: possible enemy memory leak. (minor)
16960 case eeWALK:
16961
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
16962 110 break;
16963
16964 case eeLEV:
16965 e = new eLeever((zfix)x,(zfix)y,id,clk);
16966 break;
16967
16968 case eeTEK:
16969 e = new eTektite((zfix)x,(zfix)y,id,clk);
16970 break;
16971
16972 case eePEAHAT:
16973 e = new ePeahat((zfix)x,(zfix)y,id,clk);
16974 break;
16975
16976 case eeZORA:
16977 e = new eZora((zfix)x,(zfix)y,id,clk);
16978 break;
16979
16980 case eeGHINI:
16981 e = new eGhini((zfix)x,(zfix)y,id,clk);
16982 break;
16983
16984 case eeKEESE:
16985
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
16986 1865 break;
16987
16988 case eeWIZZ:
16989
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
16990 15 break;
16991
16992 case eePROJECTILE:
16993 e = new eProjectile((zfix)x,(zfix)y,id,clk);
16994 break;
16995
16996 case eeWALLM:
16997 e = new eWallM((zfix)x,(zfix)y,id,clk);
16998 break;
16999
17000 case eeAQUA:
17001 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17002 break;
17003
17004 case eeMOLD:
17005 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17006 break;
17007
17008 case eeMANHAN:
17009
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17010 1 break;
17011
17012 case eeGLEEOK:
17013 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17014 break;
17015
17016 case eeGHOMA:
17017 e = new eGohma((zfix)x,(zfix)y,id,clk);
17018 break;
17019
17020 case eeLANM:
17021 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17022 break;
17023
17024 case eeGANON:
17025 e = new eGanon((zfix)x,(zfix)y,id,clk);
17026 break;
17027
17028 case eeFAIRY:
17029 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17030 break;
17031
17032 case eeFIRE:
17033
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17034 2 break;
17035
17036 case eeOTHER:
17037 e = new eOther((zfix)x,(zfix)y,id,clk);
17038 break;
17039
17040
17041 case eeSCRIPT01:
17042 case eeSCRIPT02:
17043 case eeSCRIPT03:
17044 case eeSCRIPT04:
17045 case eeSCRIPT05:
17046 case eeSCRIPT06:
17047 case eeSCRIPT07:
17048 case eeSCRIPT08:
17049 case eeSCRIPT09:
17050 case eeSCRIPT10:
17051 case eeSCRIPT11:
17052 case eeSCRIPT12:
17053 case eeSCRIPT13:
17054 case eeSCRIPT14:
17055 case eeSCRIPT15:
17056 case eeSCRIPT16:
17057 case eeSCRIPT17:
17058 case eeSCRIPT18:
17059 case eeSCRIPT19:
17060 case eeSCRIPT20:
17061 {
17062 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17063 {
17064 e = new eScript((zfix)x,(zfix)y,id,clk);
17065 break;
17066 }
17067 else return 0;
17068 }
17069
17070 case eeFFRIENDLY01:
17071 case eeFFRIENDLY02:
17072 case eeFFRIENDLY03:
17073 case eeFFRIENDLY04:
17074 case eeFFRIENDLY05:
17075 case eeFFRIENDLY06:
17076 case eeFFRIENDLY07:
17077 case eeFFRIENDLY08:
17078 case eeFFRIENDLY09:
17079 case eeFFRIENDLY10:
17080 {
17081 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17082 {
17083 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17084 }
17085 else return 0;
17086
17087 }
17088
17089 case eeSPINTILE:
17090 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17091 break;
17092
17093 // and these enemies use the misc10/misc2 value
17094 case eeROCK:
17095 {
17096 switch(guysbuf[id&0xFFF].attributes[9])
17097 {
17098 case 1:
17099 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17100 break;
17101
17102 case 0:
17103 default:
17104 e = new eRock((zfix)x,(zfix)y,id,clk);
17105 break;
17106 }
17107
17108 break;
17109 }
17110
17111 case eeTRAP:
17112 {
17113 switch(guysbuf[id&0xFFF].attributes[1])
17114 {
17115 case 1:
17116 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17117 break;
17118
17119 case 0:
17120 default:
17121 e = new eTrap((zfix)x,(zfix)y,id,clk);
17122 break;
17123 }
17124
17125 break;
17126 }
17127
17128 case eeDONGO:
17129 {
17130 switch(guysbuf[id&0xFFF].attributes[9])
17131 {
17132 case 1:
17133 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17134 break;
17135
17136 case 0:
17137 default:
17138 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17139 break;
17140 }
17141
17142 break;
17143 }
17144
17145 case eeDIG:
17146 {
17147
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17148 {
17149 case 1:
17150 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17151 break;
17152
17153 4 case 0:
17154 default:
17155
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17156 4 break;
17157 }
17158
17159 4 break;
17160 }
17161
17162 case eePATRA:
17163 {
17164 switch(guysbuf[id&0xFFF].attributes[9])
17165 {
17166 case 1:
17167 if (get_qr(qr_HARDCODED_BS_PATRA))
17168 {
17169 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17170 break;
17171 }
17172 [[fallthrough]];
17173 case 0:
17174 default:
17175 e = new ePatra((zfix)x,(zfix)y,id,clk);
17176 break;
17177 }
17178
17179 break;
17180 }
17181
17182 case eeGUY:
17183 {
17184 switch(guysbuf[id&0xFFF].attributes[9])
17185 {
17186 case 1:
17187 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17188 break;
17189
17190 case 0:
17191 default:
17192 e = new eNPC((zfix)x,(zfix)y,id,clk);
17193 break;
17194 }
17195
17196 break;
17197 }
17198
17199 case eeNONE:
17200 if(guysbuf[id&0xFFF].attributes[9] ==1)
17201 {
17202 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17203 break;
17204 break;
17205 }
17206 [[fallthrough]];
17207 default:
17208
17209 return 0;
17210 }
17211
17212 1997 ret++; // Made one enemy.
17213
17214
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17215 {
17216 7 e->z = (zfix)z;
17217 7 }
17218
17219
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17220 1997 e->setParent(parent);
17221
17222
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17223 {
17224 return 0;
17225 }
17226
17227 // add segments of segmented enemies
17228 1997 int32_t c=0;
17229
17230
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17231 {
17232 case eeMOLD:
17233 {
17234 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17235 id &= 0xFFF;
17236
17237 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17238 {
17239 //christ this is messy -DD
17240 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17241
17242 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17243 {
17244 al_trace("Moldorm segment %d could not be created!\n",i+1);
17245
17246 for(int32_t j=0; j<i+1; j++)
17247 guys.del(guys.Count()-1);
17248
17249 return 0;
17250 }
17251
17252 if(i>0)
17253 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17254
17255 ret++;
17256 }
17257
17258 break;
17259 }
17260
17261 case eeLANM:
17262 {
17263 id &= 0xFFF;
17264 int32_t shft = guysbuf[id].attributes[1];
17265 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17266
17267 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17268 {
17269 al_trace("Lanmola segment 1 could not be created!\n");
17270 guys.del(guys.Count()-1);
17271 return 0;
17272 }
17273
17274 ret++;
17275
17276 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17277 {
17278 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17279 {
17280 al_trace("Lanmola segment %d could not be created!\n",i+1);
17281
17282 for(int32_t j=0; j<i+1; j++)
17283 guys.del(guys.Count()-1);
17284
17285 return 0;
17286 }
17287
17288 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17289 ret++;
17290 }
17291 }
17292 break;
17293
17294 case eeMANHAN:
17295 1 id &= 0xFFF;
17296
17297
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17298 {
17299
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17300 {
17301 al_trace("Manhandla head %d could not be created!\n",i+1);
17302
17303 for(int32_t j=0; j<i+1; j++)
17304 {
17305 guys.del(guys.Count()-1);
17306 }
17307
17308 return 0;
17309 }
17310
17311 4 ret++;
17312 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17313 4 }
17314
17315 1 break;
17316
17317 case eeGLEEOK:
17318 {
17319 id &= 0xFFF;
17320
17321 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17322 {
17323 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17324 {
17325 al_trace("Gleeok head %d could not be created!\n",i+1);
17326
17327 for(int32_t j=0; j<i+1; j++)
17328 {
17329 guys.del(guys.Count()-1);
17330 }
17331
17332 return false;
17333 }
17334
17335 c-=guysbuf[id].attributes[3];
17336 ret++;
17337 }
17338 }
17339 break;
17340
17341
17342 case eePATRA:
17343 {
17344 id &= 0xFFF;
17345 int32_t outeyes = 0;
17346
17347 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17348 {
17349 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17350 {
17351 al_trace("Patra outer eye %d could not be created!\n",i+1);
17352
17353 for(int32_t j=0; j<i+1; j++)
17354 guys.del(guys.Count()-1);
17355
17356 return 0;
17357 }
17358 else
17359 outeyes++;
17360
17361 ret++;
17362 }
17363
17364 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17365 {
17366 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17367 {
17368 al_trace("Patra inner eye %d could not be created!\n",i+1);
17369
17370 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17371 guys.del(guys.Count()-1);
17372
17373 return 0;
17374 }
17375
17376 ret++;
17377 }
17378
17379 break;
17380 }
17381 }
17382
17383
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 1997 times.
3998 for (int i = 0; i < ret; i++)
17384 {
17385 2001 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17386 2001 e->screen_spawned = screen;
17387 2001 }
17388
17389 1997 return ret;
17390 1997 }
17391
17392 // Returns number of enemies/segments created
17393 102139 int32_t addenemy_z(int32_t screen,int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17394 {
17395 102139 int32_t realid = id&0xFFF;
17396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102139 times.
102139 if( realid > MAXGUYS )
17397 {
17398 return 0;
17399 }
17400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102139 times.
102139 if(id <= 0) return 0;
17401
17402 102139 int32_t ret = 0;
17403 102139 sprite *e=NULL;
17404
17405
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50146 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5212 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2797 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11855 times.
✓ Branch 10 taken 5335 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 12 times.
✓ Branch 20 taken 732 times.
✓ Branch 21 taken 758 times.
✓ Branch 22 taken 7630 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2472 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 291 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
102139 switch(guysbuf[id&0xFFF].family)
17406 {
17407 //Fixme: possible enemy memory leak. (minor)
17408 case eeWALK:
17409
3/6
✓ Branch 0 taken 50146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50146 times.
✗ Branch 5 not taken.
50146 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17410 50146 break;
17411
17412 case eeLEV:
17413
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17414 3942 break;
17415
17416 case eeTEK:
17417
3/6
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5212 times.
✗ Branch 5 not taken.
5212 e = new eTektite((zfix)x,(zfix)y,id,clk);
17418 5212 break;
17419
17420 case eePEAHAT:
17421
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17422 1825 break;
17423
17424 case eeZORA:
17425
3/6
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2797 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2797 times.
✗ Branch 5 not taken.
2797 e = new eZora((zfix)x,(zfix)y,id,clk);
17426 2797 break;
17427
17428 case eeGHINI:
17429
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17430 461 break;
17431
17432 case eeKEESE:
17433
3/6
✓ Branch 0 taken 11855 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11855 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11855 times.
✗ Branch 5 not taken.
11855 e = new eKeese((zfix)x,(zfix)y,id,clk);
17434 11855 break;
17435
17436 case eeWIZZ:
17437
3/6
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5335 times.
✗ Branch 5 not taken.
5335 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17438 5335 break;
17439
17440 case eePROJECTILE:
17441
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17442 4429 break;
17443
17444 case eeWALLM:
17445
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17446 998 break;
17447
17448 case eeAQUA:
17449
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17450 126 break;
17451
17452 case eeMOLD:
17453
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17454 618 break;
17455
17456 case eeMANHAN:
17457
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17458 149 break;
17459
17460 case eeGLEEOK:
17461
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17462 168 break;
17463
17464 case eeGHOMA:
17465
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17466 93 break;
17467
17468 case eeLANM:
17469
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17470 420 break;
17471
17472 case eeGANON:
17473
3/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
12 e = new eGanon((zfix)x,(zfix)y,id,clk);
17474 12 break;
17475
17476 case eeFAIRY:
17477
3/6
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 732 times.
✗ Branch 5 not taken.
732 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17478 732 break;
17479
17480 case eeFIRE:
17481
3/6
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 758 times.
✗ Branch 5 not taken.
758 e = new eFire((zfix)x,(zfix)y,id,clk);
17482 758 break;
17483
17484 case eeOTHER:
17485
3/6
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
7630 e = new eOther((zfix)x,(zfix)y,id,clk);
17486 7630 break;
17487
17488
17489 case eeSCRIPT01:
17490 case eeSCRIPT02:
17491 case eeSCRIPT03:
17492 case eeSCRIPT04:
17493 case eeSCRIPT05:
17494 case eeSCRIPT06:
17495 case eeSCRIPT07:
17496 case eeSCRIPT08:
17497 case eeSCRIPT09:
17498 case eeSCRIPT10:
17499 case eeSCRIPT11:
17500 case eeSCRIPT12:
17501 case eeSCRIPT13:
17502 case eeSCRIPT14:
17503 case eeSCRIPT15:
17504 case eeSCRIPT16:
17505 case eeSCRIPT17:
17506 case eeSCRIPT18:
17507 case eeSCRIPT19:
17508 case eeSCRIPT20:
17509 {
17510 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17511 {
17512 e = new eScript((zfix)x,(zfix)y,id,clk);
17513 break;
17514 }
17515 else return 0;
17516 }
17517
17518 case eeFFRIENDLY01:
17519 case eeFFRIENDLY02:
17520 case eeFFRIENDLY03:
17521 case eeFFRIENDLY04:
17522 case eeFFRIENDLY05:
17523 case eeFFRIENDLY06:
17524 case eeFFRIENDLY07:
17525 case eeFFRIENDLY08:
17526 case eeFFRIENDLY09:
17527 case eeFFRIENDLY10:
17528 {
17529 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17530 {
17531 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17532 }
17533 else return 0;
17534
17535 }
17536
17537 case eeSPINTILE:
17538
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17539 94 break;
17540
17541 // and these enemies use the misc10/misc2 value
17542 case eeROCK:
17543 {
17544
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17545 {
17546 case 1:
17547
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17548 30 break;
17549
17550 354 case 0:
17551 default:
17552
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17553 354 break;
17554 }
17555
17556 384 break;
17557 }
17558
17559 case eeTRAP:
17560 {
17561
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1640 times.
2472 switch(guysbuf[id&0xFFF].attributes[1])
17562 {
17563 case 1:
17564
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17565 832 break;
17566
17567 1640 case 0:
17568 default:
17569
3/6
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1640 times.
✗ Branch 5 not taken.
1640 e = new eTrap((zfix)x,(zfix)y,id,clk);
17570 1640 break;
17571 }
17572
17573 2472 break;
17574 }
17575
17576 case eeDONGO:
17577 {
17578
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17579 {
17580 case 1:
17581
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17582 48 break;
17583
17584 203 case 0:
17585 default:
17586
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17587 203 break;
17588 }
17589
17590 251 break;
17591 }
17592
17593 case eeDIG:
17594 {
17595
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17596 {
17597 case 1:
17598
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17599 327 break;
17600
17601 76 case 0:
17602 default:
17603
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17604 76 break;
17605 }
17606
17607 403 break;
17608 }
17609
17610 case eePATRA:
17611 {
17612
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 102 times.
291 switch(guysbuf[id&0xFFF].attributes[9])
17613 {
17614 case 1:
17615
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17616 {
17617
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17618 102 break;
17619 }
17620 [[fallthrough]];
17621 189 case 0:
17622 default:
17623
3/6
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 189 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 189 times.
✗ Branch 5 not taken.
189 e = new ePatra((zfix)x,(zfix)y,id,clk);
17624 189 break;
17625 }
17626
17627 291 break;
17628 }
17629
17630 case eeGUY:
17631 {
17632
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17633 {
17634 case 1:
17635 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17636 break;
17637
17638 5 case 0:
17639 default:
17640
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17641 5 break;
17642 }
17643
17644 5 break;
17645 }
17646
17647 case eeNONE:
17648
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17649 {
17650
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17651 533 break;
17652 }
17653 [[fallthrough]];
17654 default:
17655
17656 return 0;
17657 }
17658
17659 102139 ret++; // Made one enemy.
17660
17661
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 101962 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 152 times.
102139 if(z && canfall(id))
17662 {
17663 152 e->z = (zfix)z;
17664 152 }
17665
17666
2/2
✓ Branch 0 taken 101962 times.
✓ Branch 1 taken 177 times.
102139 ((enemy*)e)->ceiling = (z && canfall(id));
17667
17668
1/2
✓ Branch 0 taken 102139 times.
✗ Branch 1 not taken.
102139 if(!guys.add(e))
17669 {
17670 return 0;
17671 }
17672
17673 // add segments of segmented enemies
17674 102139 int32_t c=0;
17675
17676
6/6
✓ Branch 0 taken 100493 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 291 times.
102139 switch(guysbuf[id&0xFFF].family)
17677 {
17678 case eeMOLD:
17679 {
17680 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17681 618 id &= 0xFFF;
17682
17683
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17684 {
17685 //christ this is messy -DD
17686 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17687
17688
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17689 {
17690 al_trace("Moldorm segment %d could not be created!\n",i+1);
17691
17692 for(int32_t j=0; j<i+1; j++)
17693 guys.del(guys.Count()-1);
17694
17695 return 0;
17696 }
17697
17698
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17699 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17700
17701 3150 ret++;
17702 3150 }
17703
17704 618 break;
17705 }
17706
17707 case eeLANM:
17708 {
17709 420 id &= 0xFFF;
17710 420 int32_t shft = guysbuf[id].attributes[1];
17711 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17712
17713
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17714 {
17715 al_trace("Lanmola segment 1 could not be created!\n");
17716 guys.del(guys.Count()-1);
17717 return 0;
17718 }
17719
17720 420 ret++;
17721
17722
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17723 {
17724
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17725 {
17726 al_trace("Lanmola segment %d could not be created!\n",i+1);
17727
17728 for(int32_t j=0; j<i+1; j++)
17729 guys.del(guys.Count()-1);
17730
17731 return 0;
17732 }
17733
17734 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17735 1847 ret++;
17736 1847 }
17737 }
17738 420 break;
17739
17740 case eeMANHAN:
17741 149 id &= 0xFFF;
17742
17743
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17744 {
17745
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17746 {
17747 al_trace("Manhandla head %d could not be created!\n",i+1);
17748
17749 for(int32_t j=0; j<i+1; j++)
17750 {
17751 guys.del(guys.Count()-1);
17752 }
17753
17754 return 0;
17755 }
17756
17757 688 ret++;
17758 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17759 688 }
17760
17761 149 break;
17762
17763 case eeGLEEOK:
17764 {
17765 168 id &= 0xFFF;
17766 168 eGleeok* parent = (eGleeok*)e;
17767
17768
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17769 {
17770
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
17771
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
17772 {
17773 al_trace("Gleeok head %d could not be created!\n",i+1);
17774
17775 for(int32_t j=0; j<i+1; j++)
17776 {
17777 guys.del(guys.Count()-1);
17778 }
17779
17780 return false;
17781 }
17782
17783 533 head->necktile=parent->necktile;
17784 533 head->dummy_int[1]=parent->necktile;
17785
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
17786 {
17787 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
17788 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
17789 421 }
17790 else
17791 {
17792 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
17793 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
17794 }
17795 533 head->tile = head->dummy_int[2];
17796
17797 533 c-=guysbuf[id].attributes[3];
17798 533 ret++;
17799 533 }
17800 }
17801 168 break;
17802
17803
17804 case eePATRA:
17805 {
17806 291 id &= 0xFFF;
17807 291 int32_t outeyes = 0;
17808
17809
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2239 times.
✓ Branch 2 taken 1948 times.
✓ Branch 3 taken 291 times.
2239 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17810 {
17811
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1336 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1336 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1336 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1336 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1948 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17812 {
17813 al_trace("Patra outer eye %d could not be created!\n",i+1);
17814
17815 for(int32_t j=0; j<i+1; j++)
17816 guys.del(guys.Count()-1);
17817
17818 return 0;
17819 }
17820 else
17821 1948 outeyes++;
17822
17823 1948 ret++;
17824 1948 }
17825
17826
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 603 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 291 times.
603 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17827 {
17828
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17829 {
17830 al_trace("Patra inner eye %d could not be created!\n",i+1);
17831
17832 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17833 guys.del(guys.Count()-1);
17834
17835 return 0;
17836 }
17837
17838 312 ret++;
17839 312 }
17840
17841 291 break;
17842 }
17843 }
17844
17845
2/2
✓ Branch 0 taken 111037 times.
✓ Branch 1 taken 102139 times.
213176 for (int i = 0; i < ret; i++)
17846 {
17847 111037 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17848 111037 e->screen_spawned = screen;
17849 111037 }
17850
17851 102139 return ret;
17852 102139 }
17853
17854 2059282 bool isjumper(int32_t id)
17855 {
17856
2/4
✓ Branch 0 taken 2059282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2059282 times.
2059282 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17857 {
17858 return false;
17859 }
17860
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1953404 times.
✓ Branch 2 taken 105869 times.
2059282 switch(guysbuf[id&0xFFF].family)
17861 {
17862 case eeROCK:
17863 case eeTEK:
17864 9 return true;
17865
17866 case eeWALK:
17867
3/4
✓ Branch 0 taken 105869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 93604 times.
105869 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
17868 93604 }
17869
17870 2047008 return false;
17871 2059282 }
17872
17873
17874 8068 bool isfixedtogrid(int32_t id)
17875 {
17876
2/4
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8068 times.
8068 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17877 {
17878 return false;
17879 }
17880
1/2
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
8068 switch(guysbuf[id&0xFFF].family)
17881 {
17882 case eeWALK:
17883 case eeLEV:
17884 case eeZORA:
17885 case eeDONGO:
17886 case eeGANON:
17887 case eeROCK:
17888 case eeGLEEOK:
17889 case eeAQUA:
17890 case eeLANM:
17891 return true;
17892 }
17893
17894 8068 return false;
17895 8068 }
17896
17897 // Can't fall, can have Z value.
17898 52350274 bool isflier(int32_t id)
17899 {
17900
3/4
✓ Branch 0 taken 52350274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110858 times.
✓ Branch 3 taken 52239416 times.
52350274 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17901 {
17902 110858 return false;
17903 }
17904
2/2
✓ Branch 0 taken 6515554 times.
✓ Branch 1 taken 45723862 times.
52239416 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
17905 {
17906 case eePEAHAT:
17907 case eeKEESE:
17908 case eePATRA:
17909 case eeFAIRY:
17910 case eeGHINI:
17911
17912 // Could theoretically have their Z set by a script
17913 case eeFIRE:
17914 6515554 return true;
17915 break;
17916 }
17917
17918 45723862 return false;
17919 52350274 }
17920
17921 // Can't have Z position
17922 4046103 bool never_in_air(int32_t id)
17923 {
17924
2/4
✓ Branch 0 taken 4046103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4046103 times.
4046103 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17925 {
17926 return false;
17927 }
17928
2/2
✓ Branch 0 taken 4036553 times.
✓ Branch 1 taken 9550 times.
4046103 switch(guysbuf[id&0xFFF].family)
17929 {
17930 case eeMANHAN:
17931 case eeMOLD:
17932 case eeLANM:
17933 case eeGLEEOK:
17934 case eeZORA:
17935 case eeLEV:
17936 case eeAQUA:
17937 case eeROCK:
17938 case eeGANON:
17939 case eeTRAP:
17940 case eePROJECTILE:
17941 case eeSPINTILE:
17942 9550 return true;
17943 }
17944
17945 4036553 return false;
17946 4046103 }
17947
17948 2248208 bool canfall(int32_t id)
17949 {
17950
3/4
✓ Branch 0 taken 2248208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 2248162 times.
2248208 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17951 {
17952 46 return false;
17953 }
17954
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2248122 times.
✓ Branch 2 taken 40 times.
2248162 switch(guysbuf[id&0xFFF].family)
17955 {
17956 case eeGUY:
17957 {
17958
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
17959 40 return false;
17960
17961 switch(guysbuf[id&0xFFF].attributes[9])
17962 {
17963 case 1:
17964 case 2:
17965 return true;
17966
17967 case 0:
17968 case 3:
17969 default:
17970 return false;
17971 }
17972
17973 case eeGHOMA:
17974 case eeDIG:
17975 return false;
17976 }
17977 }
17978
17979
17980
4/4
✓ Branch 0 taken 2239686 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 180404 times.
✓ Branch 3 taken 2059282 times.
2248122 return !never_in_air(id) && !isflier(id) && !isjumper(id);
17981 2248208 }
17982
17983 73901041 bool enemy::enemycanfall(int32_t id, bool checkgrav)
17984 {
17985
3/4
✓ Branch 0 taken 73901041 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89598 times.
✓ Branch 3 taken 73811443 times.
73901041 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17986 {
17987 89598 return false;
17988 }
17989 //Z_scripterrlog("canfall family is %d:\n", family);
17990 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
17991 //if ( family == eeFIRE && id >= eSTART )
17992 //{
17993 // Z_scripterrlog("eeFire\n");
17994 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
17995 //}
17996
17997 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
17998
17999
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 71305031 times.
✓ Branch 2 taken 2077477 times.
73811443 switch(guysbuf[id&0xFFF].family)
18000 {
18001 case eeGUY:
18002 {
18003
1/2
✓ Branch 0 taken 2077477 times.
✗ Branch 1 not taken.
2077477 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18004 2077477 return false;
18005
18006 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
18007 {
18008 case 1:
18009 case 2:
18010 return true;
18011
18012 case 0:
18013 case 3:
18014 default:
18015 return false;
18016 }
18017
18018 case eeGHOMA:
18019 case eeDIG:
18020 428935 return false;
18021 }
18022 }
18023
18024
2/2
✓ Branch 0 taken 39106637 times.
✓ Branch 1 taken 32198394 times.
71305031 if(!checkgrav) return true;
18025 39106637 return (moveflags & move_obeys_grav);
18026
18027 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18028 // {
18029 // if ( moveflags & move_obeys_grav ) return true;
18030 // else return false;
18031 // }
18032 // else
18033 // {
18034 // return (moveflags & move_obeys_grav);
18035 // }
18036 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18037 73901041 }
18038
18039 1271 void addfires()
18040 {
18041
2/2
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 457 times.
1271 if(!get_qr(qr_NOGUYFIRES))
18042 {
18043 2285 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
18044 457 int32_t bs = get_qr(qr_BSZELDA);
18045 914 addguy(dx+(bs? 64: 72),dy+64,gFIRE,-17,false,nullptr);
18046 914 addguy(dx+(bs?176:168),dy+64,gFIRE,-18,false,nullptr);
18047 457 }
18048 1271 }
18049
18050 // This function runs one time for every screen on the first frame of a region being loaded.
18051 // It handles spawning screen guys (not the enemies), item, and room-specific sprites.
18052 37024 static void loadguys(mapscr* scr)
18053 {
18054 37024 int screen = scr->screen;
18055 37024 byte Guy=0;
18056 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18057 // Else use mITEM and ipONETIME
18058 37024 int32_t mf = (screen>=128) ? mSPECIALITEM : mITEM;
18059 37024 int32_t onetime = (screen>=128) ? ipONETIME2 : ipONETIME;
18060
18061 37024 mapscr* guyscr = scr;
18062
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 36118 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 431 times.
37024 if(screen>=128 && DMaps[cur_dmap].flags&dmfGUYCAVES)
18063 {
18064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if(DMaps[cur_dmap].flags&dmfCAVES)
18065 {
18066 431 Guy=special_warp_return_scr->guy;
18067 431 guyscr = special_warp_return_scr;
18068 431 }
18069 431 }
18070 else
18071 {
18072 36593 Guy=scr->guy;
18073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36593 times.
36593 if (game->get_regionmapping() == REGION_MAPPING_FULL)
18074 36593 mark_visited(screen);
18075 }
18076
18077 113988 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18078
18079 37024 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18080 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18081
4/4
✓ Branch 0 taken 3865 times.
✓ Branch 1 taken 33159 times.
✓ Branch 2 taken 2550 times.
✓ Branch 3 taken 1315 times.
37024 if(Guy && ((screen>=128) == !!(DMaps[cur_dmap].flags&dmfGUYCAVES)))
18082 {
18083
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1304 times.
1315 if(scr->room==rZELDA)
18084 {
18085 22 addguy(dx+120,dy+72,Guy,-15,true,guyscr);
18086 11 guys.spr(0)->hxofs=1000;
18087 33 addenemy(screen,dx+128,dy+96,eFIRE,-15);
18088 33 addenemy(screen,dx+112,dy+96,eFIRE,-15);
18089 33 addenemy(screen,dx+96,dy+120,eFIRE,-15);
18090 33 addenemy(screen,dx+144,dy+120,eFIRE,-15);
18091 11 return;
18092 }
18093
18094
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 4 times.
2604 bool ffire = oldguy
18095
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 29 times.
1300 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18096 4 : (guyscr->roomflags&RFL_GUYFIRES);
18097
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1271 times.
1304 if(ffire)
18098 1271 addfires();
18099
18100
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 425 times.
1304 if(screen>=128)
18101
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
438 if(getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))
18102 13 Guy=0;
18103
18104
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1091 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1304 switch(scr->room)
18105 {
18106 case rSP_ITEM:
18107 case rGRUMBLE:
18108 case rBOMBS:
18109 case rARROWS:
18110 case rSWINDLE:
18111 case rMUPGRADE:
18112 case rLEARNSLASH:
18113 case rTAKEONE:
18114
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18115 55 Guy=0;
18116
18117 167 break;
18118
18119 case rREPAIR:
18120 if (get_qr(qr_OLD_DOORREPAIR)) break;
18121 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18122 Guy=0;
18123
18124 break;
18125 case rRP_HC:
18126 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18127 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18128 Guy=0;
18129
18130 break;
18131 case rMONEY:
18132
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18133 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18134 Guy=0;
18135
18136 break;
18137
18138 case rTRIFORCE:
18139 {
18140 45 int32_t tc = TriforceCount();
18141
18142
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18143 {
18144
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18145 10 Guy=0;
18146 9 }
18147 else
18148 {
18149
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18150 33 Guy=0;
18151 }
18152 }
18153 43 break;
18154 }
18155
18156
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1195 times.
1302 if(Guy)
18157 {
18158
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1162 times.
1195 if(ffire)
18159 1162 blockpath=true;
18160
18161
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 783 times.
1195 if(screen<128)
18162 783 sfx(WAV_SCALE);
18163
18164
6/6
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 728 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 357 times.
2390 addguy(dx+120,dy+64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true, guyscr);
18165 1195 Hero.Freeze();
18166 1195 }
18167 1302 }
18168
5/6
✓ Branch 0 taken 33897 times.
✓ Branch 1 taken 1812 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 33826 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1812 times.
35709 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18169 {
18170 71 sfx(WAV_SCALE);
18171 142 addguy(dx+120,dy+62,gFAIRY,-14,false,guyscr);
18172 71 }
18173
18174 111033 loaditem(scr, dx, dy);
18175
18176 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18177 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18178
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36992 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
37011 if (scr->room==r10RUPIES && !getmapflag(screen, mf))
18179 {
18180
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18181 300 additem(dx+ten_rupies_x[i],dy+ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18182 15 }
18183 37022 }
18184
18185 35780 void loadguys()
18186 {
18187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35780 times.
35780 if (loaded_guys)
18188 return;
18189
18190 35780 loaded_guys = true;
18191 35780 repaircharge = 0;
18192 35780 adjustmagic = false;
18193 35780 learnslash = false;
18194
2/2
✓ Branch 0 taken 107340 times.
✓ Branch 1 taken 35780 times.
143120 for (int32_t i=0; i<3; i++)
18195 {
18196 107340 prices[i] = 0;
18197 107340 }
18198
18199 72804 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18200 37024 get_screen_state(scr->screen).item_state = ScreenItemState::None;
18201 37024 loadguys(scr);
18202 37024 });
18203 35780 }
18204
18205 37029 void loaditem(mapscr* scr, int offx, int offy)
18206 {
18207 37029 int screen = scr->screen;
18208 37029 byte Item = 0;
18209
18210
2/2
✓ Branch 0 taken 36123 times.
✓ Branch 1 taken 906 times.
37029 if(screen<128)
18211 {
18212 36123 Item=scr->item;
18213
18214
4/4
✓ Branch 0 taken 1592 times.
✓ Branch 1 taken 34531 times.
✓ Branch 2 taken 32904 times.
✓ Branch 3 taken 3219 times.
36123 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
18215 {
18216
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3160 times.
3219 if(scr->flags8&fSECRETITEM)
18217 59 screen_item_set_state(screen, ScreenItemState::WhenTriggerSecrets);
18218
2/2
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 1996 times.
3160 else if(scr->flags&fITEM)
18219 1164 screen_item_set_state(screen, ScreenItemState::WhenKillEnemies);
18220
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 1887 times.
1996 else if(scr->flags11&efCARRYITEM)
18221 109 screen_item_set_state(screen, ScreenItemState::MustGiveToEnemy); // Will be set to CarriedByEnemy in roaming_item
18222 else
18223 {
18224 1887 int x = scr->itemx;
18225
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1872 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
1887 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18226 -170 :
18227 1887 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18228
3/6
✓ Branch 0 taken 1887 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1887 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1887 times.
✗ Branch 5 not taken.
3774 add_item_for_screen(screen, new item(offx + x, offy + y,
18229
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1872 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1872 times.
✗ Branch 9 not taken.
1887 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18230
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1782 times.
1887 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
18231 1887 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18232 }
18233 3219 }
18234 36123 }
18235
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 475 times.
906 else if(!(DMaps[cur_dmap].flags&dmfCAVES))
18236 {
18237
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (special_warp_return_scr->flags9&fBELOWRETURN)) && special_warp_return_scr->room==rSP_ITEM
18238
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (screen==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18239 {
18240 163 Item = special_warp_return_scr->catchall;
18241
18242
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18243 {
18244 162 int x = scr->itemx;
18245
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18246 -170 :
18247 162 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18248
3/6
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
324 add_item_for_screen(screen, new item(offx + x, offy + y,
18249
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18250 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18251 162 }
18252 163 }
18253 475 }
18254 37029 }
18255
18256 956 void never_return(int32_t screen, int32_t index)
18257 {
18258
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 190 times.
956 if(!get_qr(qr_KILLALL))
18259 190 goto doit;
18260
18261
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18262
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18263 {
18264 437 goto dontdoit;
18265 329 }
18266
18267 doit:
18268 519 setmapflag(get_scr(screen), mNEVERRET);
18269 dontdoit:
18270 956 return;
18271 }
18272
18273 63752 bool slowguy(int32_t id)
18274 {
18275
2/4
✓ Branch 0 taken 63752 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63752 times.
63752 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18276 {
18277 return false;
18278 }
18279
18280 63752 id = id&0xFFF;
18281
18282
2/2
✓ Branch 0 taken 54109 times.
✓ Branch 1 taken 9643 times.
63752 switch(id)
18283 {
18284 case eOCTO1S:
18285 case eOCTO2S:
18286 case eOCTO1F:
18287 case eOCTO2F:
18288 case eLEV1:
18289 case eLEV2:
18290 case eROCK:
18291 case eBOULDER:
18292 9643 return true;
18293 }
18294
18295 54109 return false;
18296 63752 }
18297
18298 83362 static bool ok2add(mapscr* scr, int32_t id)
18299 {
18300
2/4
✓ Branch 0 taken 83362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83362 times.
83362 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18301 {
18302 return false;
18303 }
18304
18305 83362 id = id&0xFFF;
18306
18307
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 82533 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
83362 if(getmapflag(scr, mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18308 464 return false;
18309
18310
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 82257 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82898 switch(guysbuf[id].family)
18311 {
18312 // I added a special case for shooters because having traps on the same screen
18313 // was preventing them from spawning due to TMPNORET. This means they will
18314 // never stay dead, though, so it may not be the best solution. - Saf
18315 case eePROJECTILE:
18316 376 return true;
18317
18318
18319 case eeDIG:
18320 {
18321
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18322 {
18323 case 1:
18324
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18325 79 return !getmapflag(scr, mTMPNORET);
18326
18327 47 return true;
18328
18329 75 case 0:
18330 default:
18331 75 return true;
18332 }
18333 }
18334 case eeGANON:
18335 case eeTRAP:
18336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18337
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18338 [[fallthrough]];
18339 default:
18340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82257 times.
82257 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18341 82257 break;
18342 }
18343
18344
2/2
✓ Branch 0 taken 20977 times.
✓ Branch 1 taken 61280 times.
82257 if(!get_qr(qr_NOTMPNORET))
18345 61280 return !getmapflag(scr, mTMPNORET);
18346
18347 20977 return true;
18348 83362 }
18349
18350 1634099 static void activate_fireball_statue(const rpos_handle_t& rpos_handle)
18351 {
18352
3/4
✓ Branch 0 taken 288841 times.
✓ Branch 1 taken 1345258 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288841 times.
1634099 if (!(rpos_handle.scr->flags11&efFIREBALLS) || statueID<0)
18353 {
18354 1345258 return;
18355 }
18356
18357 288841 int32_t ctype = rpos_handle.ctype();
18358
6/6
✓ Branch 0 taken 287333 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 286018 times.
✓ Branch 3 taken 1315 times.
✓ Branch 4 taken 1213 times.
✓ Branch 5 taken 284805 times.
288841 if (ctype != cL_STATUE && ctype != cR_STATUE && ctype != cC_STATUE) return;
18359
18360 12108 auto [x, y] = rpos_handle.xy();
18361
18362 4036 int32_t cx=-1000, cy=-1000;
18363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(!isfixedtogrid(statueID))
18364 {
18365
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 2528 times.
4036 if(ctype==cL_STATUE)
18366 {
18367 1508 cx=x+4;
18368 1508 cy=y+7;
18369 1508 }
18370
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 1213 times.
2528 else if(ctype==cR_STATUE)
18371 {
18372 1315 cx=x-8;
18373 1315 cy=y-1;
18374 1315 }
18375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 else if(ctype==cC_STATUE)
18376 {
18377 1213 cx=x;
18378 1213 cy=y;
18379 1213 }
18380 4036 }
18381 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18382 {
18383 cx=x;
18384 cy=y;
18385 }
18386
18387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(cx!=-1000) // No point creating it if this is false
18388 {
18389
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18390 {
18391
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18392 {
18393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18394 4 return; // No point deleting it. A script might be toying with it in some way.
18395 else
18396 guys.del(j);
18397 }
18398 9750 }
18399
18400 4032 addenemy(rpos_handle.screen, cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18401 4032 }
18402 1634099 }
18403
18404 34366 static void activate_fireball_statues(mapscr* scr)
18405 {
18406
2/2
✓ Branch 0 taken 32947 times.
✓ Branch 1 taken 1419 times.
34366 if (!(scr->flags11&efFIREBALLS))
18407 {
18408 32947 return;
18409 }
18410
18411 251163 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18412 249744 activate_fireball_statue(rpos_handle);
18413 249744 });
18414 34366 }
18415
18416 35049 void load_default_enemies(mapscr* scr)
18417 {
18418 35049 int screen = scr->screen;
18419 40514 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18420
18421 35049 wallm_load_clk=frame-80;
18422
18423
2/2
✓ Branch 0 taken 33153 times.
✓ Branch 1 taken 1896 times.
35049 if(scr->flags11&efZORA)
18424 {
18425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1896 times.
1896 if(zoraID>=0)
18426 5688 addenemy(screen, dx - 16, dy - 16, zoraID, 0);
18427 1896 }
18428
18429
2/2
✓ Branch 0 taken 34871 times.
✓ Branch 1 taken 178 times.
35049 if(scr->flags11&efTRAP4)
18430 {
18431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18432 {
18433 534 addenemy(screen, dx + 32, dy + 32, cornerTrapID, -14);
18434 534 addenemy(screen, dx + 208, dy + 32, cornerTrapID, -14);
18435 534 addenemy(screen, dx + 32, dy + 128, cornerTrapID, -14);
18436 534 addenemy(screen, dx + 208, dy + 128, cornerTrapID, -14);
18437 178 }
18438 178 }
18439
18440 6203673 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18441 6168624 int32_t ctype = rpos_handle.ctype();
18442 6168624 int32_t cflag = rpos_handle.sflag();
18443 6168624 int32_t cflag_i = rpos_handle.cflag();
18444
18445
4/6
✓ Branch 0 taken 6168624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6168278 times.
✓ Branch 3 taken 346 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6168278 times.
6168624 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18446 {
18447 346 auto [x, y] = rpos_handle.xy();
18448
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 336 times.
346 if(trapLOSHorizontalID>=0)
18449 1008 addenemy(screen, x, y, trapLOSHorizontalID, -14);
18450 346 }
18451
4/6
✓ Branch 0 taken 6168278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6168072 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6168072 times.
6168278 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18452 {
18453 206 auto [x, y] = rpos_handle.xy();
18454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18455 618 addenemy(screen, x, y, trapLOSVerticalID, -14);
18456 206 }
18457
4/6
✓ Branch 0 taken 6168072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167794 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167794 times.
6168072 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18458 {
18459 278 auto [x, y] = rpos_handle.xy();
18460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18461 {
18462
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
834 if(addenemy(screen, x, y, trapLOS4WayID, -14))
18463 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18464 278 }
18465 278 }
18466
4/6
✓ Branch 0 taken 6167794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167395 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167395 times.
6167794 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18467 {
18468 399 auto [x, y] = rpos_handle.xy();
18469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18470 1197 addenemy(screen, x, y, trapConstantHorizontalID, -14);
18471 399 }
18472
4/6
✓ Branch 0 taken 6167395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6166962 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6166962 times.
6167395 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18473 {
18474 433 auto [x, y] = rpos_handle.xy();
18475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18476 1299 addenemy(screen, x, y, trapConstantVerticalID, -14);
18477 433 }
18478
18479
1/2
✓ Branch 0 taken 6168624 times.
✗ Branch 1 not taken.
6168624 if(ctype==cSPINTILE1)
18480 {
18481 awaken_spinning_tile(rpos_handle);
18482 }
18483 6168624 });
18484
18485
2/2
✓ Branch 0 taken 34993 times.
✓ Branch 1 taken 56 times.
35049 if(scr->flags11&efTRAP2)
18486 {
18487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18488 {
18489
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 64, 80, centerTrapID, -14))
18490 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18491
18492
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 176, 80, centerTrapID, -14))
18493 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18494 56 }
18495 56 }
18496
18497
2/2
✓ Branch 0 taken 34966 times.
✓ Branch 1 taken 83 times.
35049 if(scr->flags11&efROCKS)
18498 {
18499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18500 {
18501 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18502 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18503 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18504 83 }
18505 83 }
18506 35049 }
18507
18508 #define SLOPE_STAGE_COMBOS 0
18509 #define SLOPE_STAGE_FFCS 1
18510 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18511
18512 20917066 static slope_id_t create_slope_id(int stage, int arg1, int arg2)
18513 {
18514
2/2
✓ Branch 0 taken 4645399 times.
✓ Branch 1 taken 16271667 times.
20917066 if (stage == SLOPE_STAGE_COMBOS)
18515 16271667 return (region_num_rpos*arg1)+arg2;
18516
2/2
✓ Branch 0 taken 4500554 times.
✓ Branch 1 taken 144845 times.
4645399 if (stage == SLOPE_STAGE_FFCS)
18517 4500554 return (region_num_rpos*7)+arg1;
18518
1/2
✓ Branch 0 taken 144845 times.
✗ Branch 1 not taken.
144845 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18519 144845 return (region_num_rpos*7 + MAX_FFCID+1)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18520 // TODO: what about FFCs from bordering screens?
18521
18522 assert(false);
18523 return 0;
18524 20917066 }
18525
18526 16271667 void update_slope_combopos(const rpos_handle_t& rpos_handle)
18527 {
18528 16271667 mapscr* s = rpos_handle.scr;
18529 16271667 auto& cmb = rpos_handle.combo();
18530
18531 16271667 auto id = create_slope_id(SLOPE_STAGE_COMBOS, rpos_handle.layer, (int)rpos_handle.rpos);
18532 16271667 auto it = slopes.find(id);
18533
18534 16271667 bool wasSlope = it!=slopes.end();
18535 16271667 bool isSlope = cmb.type == cSLOPE;
18536
18537
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 16271531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
16271667 if(isSlope && !wasSlope)
18538 {
18539 272 auto [x, y] = rpos_handle.xy();
18540 272 slopes.try_emplace(id, &(s->data[rpos_handle.pos]), nullptr, -1, x, y);
18541 136 }
18542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16271531 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16271531 else if(wasSlope && !isSlope)
18543 {
18544 slopes.erase(it);
18545 }
18546 16271667 }
18547
18548 144845 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18549 {
18550 144845 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18551 144845 auto it = slopes.find(id);
18552
18553 144845 bool wasSlope = it!=slopes.end();
18554 144845 bool isSlope = is_slope;
18555
18556
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144845 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144845 if(isSlope && !wasSlope)
18557 {
18558 static std::vector<word> TMP;
18559 int num_border_combos = cur_region.screen_width*16 * 2 + cur_region.screen_height*11 * 2;
18560 TMP.resize(num_border_combos * 7 * 4);
18561
18562 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18563 TMP[tmp_index] = cid;
18564 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18565 }
18566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144845 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144845 else if(wasSlope && !isSlope)
18567 {
18568 slopes.erase(it);
18569 }
18570 144845 }
18571
18572 // Load a single column or row from a nearby screen, and load its slopes.
18573 3880 static void handle_slope_combopos_bordering_screen(int initial_screen, int dir)
18574 {
18575 55806 auto [map, screen] = nextscr2(cur_map, initial_screen, dir);
18576
2/2
✓ Branch 0 taken 3709 times.
✓ Branch 1 taken 171 times.
3880 if (map == -1)
18577 171 return;
18578
18579 3709 int offx = 0;
18580 3709 int offy = 0;
18581
2/2
✓ Branch 0 taken 2797 times.
✓ Branch 1 taken 912 times.
3709 if (dir == up)
18582 912 offy = -16;
18583
2/2
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 1936 times.
2797 else if (dir == down)
18584 861 offy = world_h;
18585
2/2
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 969 times.
1936 else if (dir == left)
18586 967 offx = -16;
18587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 969 times.
969 else if (dir == right)
18588 969 offx = world_w;
18589
18590
2/2
✓ Branch 0 taken 3709 times.
✓ Branch 1 taken 25963 times.
29672 for (int layer = 0; layer < 7; layer++)
18591 {
18592 51926 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18593
2/2
✓ Branch 0 taken 10820 times.
✓ Branch 1 taken 15143 times.
25963 if (!scr) continue;
18594
18595 10820 int slope_count = layer * (16*2);
18596
18597
4/4
✓ Branch 0 taken 7995 times.
✓ Branch 1 taken 2825 times.
✓ Branch 2 taken 2830 times.
✓ Branch 3 taken 5165 times.
10820 if (dir == left || dir == right)
18598 {
18599 5655 int x = dir == left ? 15 : 0;
18600
2/2
✓ Branch 0 taken 62205 times.
✓ Branch 1 taken 5655 times.
67860 for (int y = 0; y < 11; y++)
18601 {
18602 62205 int pos = y * 16 + x;
18603 62205 int cid = scr->data[pos];
18604 62205 bool is_slope = combobuf[cid].type == cSLOPE;
18605
1/2
✓ Branch 0 taken 62205 times.
✗ Branch 1 not taken.
62205 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18606 62205 }
18607 5655 }
18608
3/4
✓ Branch 0 taken 2494 times.
✓ Branch 1 taken 2671 times.
✓ Branch 2 taken 2494 times.
✗ Branch 3 not taken.
5165 else if (dir == up || dir == down)
18609 {
18610 5165 int y = dir == up ? 10 : 0;
18611
2/2
✓ Branch 0 taken 82640 times.
✓ Branch 1 taken 5165 times.
87805 for (int x = 0; x < 16; x++)
18612 {
18613 82640 int pos = y * 16 + x;
18614 82640 int cid = scr->data[pos];
18615 82640 bool is_slope = combobuf[cid].type == cSLOPE;
18616
1/2
✓ Branch 0 taken 82640 times.
✗ Branch 1 not taken.
82640 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18617 82640 }
18618 5165 }
18619
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15143 times.
✓ Branch 2 taken 10820 times.
25963 }
18620 3880 }
18621
18622 35861 void update_slope_comboposes()
18623 {
18624 14923173 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18625 14887312 update_slope_combopos(rpos_handle);
18626 14887312 });
18627
18628
2/2
✓ Branch 0 taken 34891 times.
✓ Branch 1 taken 970 times.
35861 if (Hero.sideview_mode())
18629 {
18630 1940 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18631
2/2
✓ Branch 0 taken 3880 times.
✓ Branch 1 taken 970 times.
4850 for (int dir = up; dir <= right; dir++)
18632 3880 handle_slope_combopos_bordering_screen(scr->screen, dir);
18633 970 });
18634 970 }
18635
18636 35861 update_slopes();
18637 35861 }
18638
18639 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18640 1384355 void screen_combo_modify_preroutine(const rpos_handle_t& rpos_handle)
18641 {
18642 1384355 delete_fireball_shooter(rpos_handle);
18643 1384355 }
18644
18645 //Placeholder in case we need it.
18646 void screen_ffc_modify_preroutine(const ffc_handle_t& ffc_handle)
18647 {
18648 return;
18649 }
18650
18651 // Everything that must be done after we change a screen's combo to another combo. -L
18652 1384355 void screen_combo_modify_postroutine(const rpos_handle_t& rpos_handle)
18653 {
18654 1384355 rpos_handle.scr->valid |= mVALID;
18655 1384355 activate_fireball_statue(rpos_handle);
18656
18657
2/2
✓ Branch 0 taken 1384261 times.
✓ Branch 1 taken 94 times.
1384355 if(rpos_handle.ctype()==cSPINTILE1)
18658 {
18659 94 awaken_spinning_tile(rpos_handle);
18660 94 }
18661
18662 1384355 update_slope_combopos(rpos_handle);
18663 1384355 }
18664
18665 4500554 void screen_ffc_modify_postroutine(const ffc_handle_t& ffc_handle)
18666 {
18667 4500554 ffcdata* ff = ffc_handle.ffc;
18668 4500554 auto& cmb = ffc_handle.combo();
18669
18670 4500554 auto id = create_slope_id(SLOPE_STAGE_FFCS, ffc_handle.id, -1);
18671 4500554 auto it = slopes.find(id);
18672
18673 4500554 bool wasSlope = it!=slopes.end();
18674
1/2
✓ Branch 0 taken 4500554 times.
✗ Branch 1 not taken.
4500554 bool isSlope = cmb.type == cSLOPE && !(ff->flags&ffc_changer);
18675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500554 if(isSlope && !wasSlope)
18676 {
18677 slopes.try_emplace(id, nullptr, ff, ffc_handle.id);
18678 }
18679
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500554 else if(wasSlope && !isSlope)
18680 {
18681 slopes.erase(it);
18682 }
18683
18684 4500554 ffc_handle.scr->ffcCountMarkDirty();
18685 4500554 }
18686
18687 4414 void screen_combo_modify_pre(int32_t cid)
18688 {
18689 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18690
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18691 {
18692 5195 screen_combo_modify_preroutine(rpos_handle);
18693 5195 }
18694 2808608 });
18695 4414 }
18696 4414 void screen_combo_modify_post(int32_t cid)
18697 {
18698 4414 combo_caches::refresh(cid);
18699
18700 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18701
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18702 {
18703 5195 screen_combo_modify_postroutine(rpos_handle);
18704 5195 }
18705 2808608 });
18706
18707 144186 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
18708
2/2
✓ Branch 0 taken 139714 times.
✓ Branch 1 taken 58 times.
139772 if (ffc_handle.data() == cid)
18709 {
18710 58 screen_ffc_modify_postroutine(ffc_handle);
18711 58 }
18712 139772 });
18713 4414 }
18714
18715 94 void awaken_spinning_tile(const rpos_handle_t& rpos_handle)
18716 {
18717 94 int cid = rpos_handle.data();
18718 94 int cset = rpos_handle.cset();
18719 282 auto [x, y] = rpos_handle.xy();
18720
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
282 addenemy(rpos_handle.screen, x, y, (cset<<12)+eSPINTILE1, combobuf[cid].o_tile + zc_max(1,combobuf[cid].frames));
18721 94 }
18722
18723 // It stands for next_side_pos
18724 // moves sle_x and sle_y to the next position
18725 11464 void nsp(bool random)
18726 {
18727
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8203 times.
11464 if(random)
18728 {
18729
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18730 {
18731 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18732 1634 sle_y = (zc_oldrand()%10)*16;
18733 1634 }
18734 else
18735 {
18736 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18737 1627 sle_x = (zc_oldrand()%15)*16;
18738 }
18739
18740 3261 return;
18741 }
18742
18743
2/2
✓ Branch 0 taken 6168 times.
✓ Branch 1 taken 2035 times.
8203 if(sle_x==0)
18744 {
18745
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 180 times.
2035 if(sle_y<160)
18746 1855 sle_y+=16;
18747 else
18748 180 sle_x+=16;
18749 2035 }
18750
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 3572 times.
6168 else if(sle_y==160)
18751 {
18752
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 166 times.
2596 if(sle_x<240)
18753 2430 sle_x+=16;
18754 else
18755 166 sle_y-=16;
18756 2596 }
18757
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2020 times.
3572 else if(sle_x==240)
18758 {
18759
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 148 times.
1552 if(sle_y>0)
18760 1404 sle_y-=16;
18761 else
18762 148 sle_x-=16;
18763 1552 }
18764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18765 {
18766
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18767 2020 sle_x-=16;
18768 else
18769 sle_y+=16;
18770 2020 }
18771 11464 }
18772
18773 // moves sle_x and sle_y to the next available position
18774 // returns the direction the enemy should face
18775 2429 int32_t next_side_pos(int32_t screen, bool random)
18776 {
18777 bool blocked;
18778 2429 int32_t c=0;
18779 25357 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
18780
18781 2429 do
18782 {
18783
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11333 times.
11464 nsp(c>35 ? false : random);
18784 22928 int x = sle_x + offx;
18785 22928 int y = sle_y + offy;
18786
4/4
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2428 times.
13892 blocked = _walkflag(x,y,2) || _walkflag(x,y+8,2) ||
18787
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 (combo_class_buf[COMBOTYPE(x,y)].block_enemies ||
18788
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2428 times.
✗ Branch 3 not taken.
2428 MAPFLAG(x,y) == mfNOENEMY || MAPCOMBOFLAG(x,y)==mfNOENEMY ||
18789
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2428 times.
2428 MAPFLAG(x,y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(x,y)==mfNOGROUNDENEMY ||
18790 2428 iswaterex_z3(MAPCOMBO(x,y), -1, x, y, true));
18791
18792
2/2
✓ Branch 0 taken 11463 times.
✓ Branch 1 taken 1 times.
11464 if(++c>50)
18793 1 return -1;
18794
2/2
✓ Branch 0 taken 9035 times.
✓ Branch 1 taken 2428 times.
11463 }
18795 11463 while(blocked);
18796
18797 2428 int32_t dir=0;
18798
18799
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 736 times.
2428 if(sle_x==0) dir=right;
18800
18801
2/2
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 569 times.
2428 if(sle_y==0) dir=down;
18802
18803
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 708 times.
2428 if(sle_x==240) dir=left;
18804
18805
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(sle_y==168) dir=up;
18806
18807 2428 return dir;
18808 2429 }
18809
18810 bool can_side_load(int32_t id)
18811 {
18812 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18813 {
18814 return false;
18815 }
18816
18817 id = id&0xFFF;
18818
18819 switch(guysbuf[id].family)
18820 {
18821 case eeTEK:
18822 case eeLEV:
18823 case eeAQUA:
18824 case eeDONGO:
18825 case eeMANHAN:
18826 case eeGLEEOK:
18827 case eeDIG:
18828 case eeGHOMA:
18829 case eeLANM:
18830 case eePATRA:
18831 case eeGANON:
18832 case eePROJECTILE:
18833 return false;
18834 break;
18835 }
18836
18837 return true;
18838 }
18839
18840 bool enemy_spawning_has_checked_been_here;
18841 static bool enemy_spawning_has_been_here;
18842
18843 35049 static bool check_if_recently_visited()
18844 {
18845
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 34527 times.
35049 if (enemy_spawning_has_checked_been_here)
18846 522 return enemy_spawning_has_been_here;
18847
18848 34527 int mi = mapind(cur_map, cur_screen);
18849
18850 34527 enemy_spawning_has_been_here = false;
18851
2/2
✓ Branch 0 taken 207162 times.
✓ Branch 1 taken 34527 times.
241689 for (int i = 0; i < 6; i++)
18852
2/2
✓ Branch 0 taken 197577 times.
✓ Branch 1 taken 9585 times.
216747 if (visited[i] == mi)
18853 9585 enemy_spawning_has_been_here = true;
18854
18855
2/2
✓ Branch 0 taken 9585 times.
✓ Branch 1 taken 24942 times.
34527 if (!enemy_spawning_has_been_here)
18856 {
18857 24942 visited[vhead] = mi; //If not, it adds it to the array,
18858 24942 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
18859 24942 }
18860
18861 34527 enemy_spawning_has_checked_been_here = true;
18862 34527 return enemy_spawning_has_been_here;
18863 35049 }
18864
18865 static std::array<bool, MAPSCRS> script_sle;
18866
18867 static int32_t sle_pattern = 0;
18868 static void script_side_load_enemies(mapscr* scr)
18869 {
18870 if (script_sle[scr->screen] || sle_clk) return;
18871
18872 sle_cnt = 0;
18873 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18874 ++sle_cnt;
18875 script_sle[scr->screen] = true;
18876 sle_pattern = scr->pattern;
18877 sle_clk = 0;
18878 }
18879
18880 54516 static void side_load_enemies(mapscr* scr)
18881 {
18882 54516 int screen = scr->screen;
18883
18884
3/4
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 53833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 683 times.
54516 if (sle_clk==0 && !script_sle[scr->screen])
18885 {
18886 683 sle_pattern = scr->pattern;
18887 683 sle_cnt = 0;
18888 683 int32_t guycnt = 0;
18889
18890 683 int mi = mapind(cur_map, screen);
18891 683 bool reload=true;
18892 683 bool unbeatablereload = true;
18893
18894 683 load_default_enemies(scr);
18895
18896 683 bool beenhere = check_if_recently_visited();
18897
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 42 times.
683 if (beenhere && game->guys[mi] == 0)
18898 {
18899 42 sle_cnt=0;
18900 42 reload=false;
18901 42 }
18902
18903
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 641 times.
683 if(reload)
18904 {
18905 641 sle_cnt = game->guys[mi];
18906
18907
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 221 times.
641 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
18908 641 || sle_cnt==0)
18909 {
18910
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1272 times.
✓ Branch 2 taken 1054 times.
✓ Branch 3 taken 221 times.
1275 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18911 1054 ++sle_cnt;
18912 221 }
18913
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
641 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
18914 {
18915 for(int32_t i = 0; i<sle_cnt && scr->enemy[i]>0; i++)
18916 {
18917 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
18918 {
18919 unbeatablereload = false;
18920 }
18921 }
18922 if (unbeatablereload)
18923 {
18924 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18925 {
18926 ++sle_cnt;
18927 }
18928 }
18929 }
18930 641 }
18931
18932
3/4
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652 times.
683 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN))
18933 {
18934 31 sle_cnt = 0;
18935
18936
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18937 108 ++sle_cnt;
18938 31 }
18939
18940
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 683 times.
3129 for(int32_t i=0; i<sle_cnt; i++)
18941 2446 ++guycnt;
18942
18943 683 game->guys[mi] = guycnt;
18944 683 }
18945
18946
2/2
✓ Branch 0 taken 52087 times.
✓ Branch 1 taken 2429 times.
54516 if((++sle_clk+8)%24 == 0)
18947 {
18948 2429 int32_t dir = next_side_pos(screen, sle_pattern==pSIDESR);
18949 6819 auto [x, y] = translate_screen_coordinates_to_world(screen, sle_x, sle_y);
18950
18951
6/6
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 233 times.
✓ Branch 5 taken 2195 times.
2429 if(dir==-1 || tooclose(x,y,32))
18952 {
18953 234 return;
18954 }
18955
18956 2195 int32_t enemy_slot=guys.Count();
18957
18958
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
2195 while(sle_cnt > 0 && !ok2add(scr, scr->enemy[sle_cnt-1]))
18959 sle_cnt--;
18960
18961
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if(sle_cnt > 0)
18962 {
18963
3/6
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2195 times.
✗ Branch 5 not taken.
6585 if(addenemy(screen, x,y,scr->enemy[--sle_cnt],0))
18964 {
18965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
18966 {
18967 2195 guys.spr(enemy_slot)->dir = dir;
18968 2195 }
18969
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
18970 {
18971 if (!FFCore.system_suspend[susptNPCSCRIPTS])
18972 {
18973 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
18974 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
18975 }
18976 }
18977 2195 }
18978 2195 }
18979 2195 }
18980
18981
2/2
✓ Branch 0 taken 53704 times.
✓ Branch 1 taken 578 times.
54282 if(sle_cnt<=0)
18982 {
18983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if (script_sle[screen])
18984 script_sle[screen] = false;
18985 else
18986 {
18987 578 get_screen_state(screen).loaded_enemies = true;
18988 }
18989 578 sle_clk = 0;
18990 578 }
18991 54516 }
18992
18993 1253524 bool is_starting_pos(mapscr* scr, int32_t i, int32_t x, int32_t y, int32_t t)
18994 {
18995
2/2
✓ Branch 0 taken 116390 times.
✓ Branch 1 taken 1137134 times.
1253524 if (!is_in_scrolling_region())
18996
2/4
✓ Branch 0 taken 1137134 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1137134 times.
1137134 if(scr->enemy[i]<1||scr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
18997 {
18998 return false; //never 0, never OoB.
18999 }
19000 // No corner enemies
19001
6/6
✓ Branch 0 taken 1082515 times.
✓ Branch 1 taken 171009 times.
✓ Branch 2 taken 41283 times.
✓ Branch 3 taken 1123798 times.
✓ Branch 4 taken 117940 times.
✓ Branch 5 taken 94352 times.
1253524 if ((x==0 || x==world_w-16) && (y==0 || y==world_h-16))
19002 212292 return false;
19003
19004 //Is a no spawn combo...
19005
4/4
✓ Branch 0 taken 1123786 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1123790 times.
1123798 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19006 16 return false;
19007
19008 // No enemies in dungeon walls
19009
2/2
✓ Branch 0 taken 468703 times.
✓ Branch 1 taken 655087 times.
1123790 if (isdungeon(scr->screen))
19010 {
19011 655087 auto [offx, offy] = translate_screen_coordinates_to_world(scr->screen);
19012
17/18
✓ Branch 0 taken 655087 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582527 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 582527 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 509967 times.
✓ Branch 7 taken 72560 times.
✓ Branch 8 taken 509967 times.
✓ Branch 9 taken 72560 times.
✓ Branch 10 taken 422895 times.
✓ Branch 11 taken 87072 times.
✓ Branch 12 taken 422895 times.
✓ Branch 13 taken 87072 times.
✓ Branch 14 taken 87072 times.
✓ Branch 15 taken 335823 times.
✓ Branch 16 taken 87072 times.
✓ Branch 17 taken 335823 times.
655087 if(isdungeon(scr->screen) && (x<32+offx || x>=224+offx || y<32+offy || y>=144+offy))
19013 319264 return false;
19014 335823 }
19015
19016 // Too close to hero
19017
4/4
✓ Branch 0 taken 77037 times.
✓ Branch 1 taken 727489 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 76936 times.
804526 if(tooclose(x,y,40) && t<11)
19018 76936 return false;
19019
19020 // Can't fly onto it?
19021
4/4
✓ Branch 0 taken 139610 times.
✓ Branch 1 taken 587980 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 25255 times.
788805 if(isflier(scr->enemy[i])&&
19022
2/2
✓ Branch 0 taken 139220 times.
✓ Branch 1 taken 390 times.
139610 (flyerblocked(x+8,y+8,spw_floater,guysbuf[scr->enemy[i]])||
19023
2/2
✓ Branch 0 taken 61215 times.
✓ Branch 1 taken 78005 times.
139220 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19024 25645 return false;
19025
19026 // Can't jump onto it?
19027 if
19028 (
19029
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 88704 times.
790653 guysbuf[scr->enemy[i]].family==eeTEK
19030
19031
2/2
✓ Branch 0 taken 88722 times.
✓ Branch 1 taken 613223 times.
701945 &&
19032 (
19033
2/2
✓ Branch 0 taken 88715 times.
✓ Branch 1 taken 7 times.
88722 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19034
2/2
✓ Branch 0 taken 88714 times.
✓ Branch 1 taken 1 times.
88715 COMBOTYPE(x+8,y+8)==cNOENEMY||
19035
1/2
✓ Branch 0 taken 88714 times.
✗ Branch 1 not taken.
88714 ispitfall(x+8,y+8)||
19036
2/2
✓ Branch 0 taken 88708 times.
✓ Branch 1 taken 6 times.
88714 MAPFLAG(x+8,y+8)==mfNOENEMY||
19037 88708 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19038 )
19039 )
19040 {
19041 18 return false;
19042 }
19043
19044 // Other off-limit combos
19045
6/6
✓ Branch 0 taken 587958 times.
✓ Branch 1 taken 113969 times.
✓ Branch 2 taken 499254 times.
✓ Branch 3 taken 88704 times.
✓ Branch 4 taken 276494 times.
✓ Branch 5 taken 222760 times.
1201181 if((!isflier(scr->enemy[i])&& guysbuf[scr->enemy[i]].family!=eeTEK &&
19046
2/2
✓ Branch 0 taken 282052 times.
✓ Branch 1 taken 217202 times.
499254 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[scr->enemy[i]]))) &&
19047 499254 guysbuf[scr->enemy[i]].family!=eeZORA)
19048 222760 return false;
19049
19050 // Don't ever generate enemies on these combos!
19051
4/4
✓ Branch 0 taken 478863 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 478869 times.
479167 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19052 310 return false;
19053
19054 //BS Dodongos need at least 2 spaces.
19055
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 477830 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
478869 if ((guysbuf[scr->enemy[i]].family==eeDONGO)&&(guysbuf[scr->enemy[i]].attributes[9] == 1))
19056 {
19057
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19058
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19059
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19060 ((y>144)||_walkflag(x, y+24,2)))
19061 {
19062 return false;
19063 }
19064 19 }
19065
19066 478863 return true;
19067 1147382 }
19068
19069 160636 bool is_ceiling_pattern(int32_t i)
19070 {
19071
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 160616 times.
160636 return (i==pCEILING || i==pCEILINGR);
19072 }
19073
19074 5955 rpos_t placeenemy(mapscr* scr, int32_t i, int32_t offx, int32_t offy)
19075 {
19076 5955 std::vector<rpos_t> freeposcache;
19077
19078
2/2
✓ Branch 0 taken 65505 times.
✓ Branch 1 taken 5955 times.
71460 for(int32_t y=offy; y<offy+176; y+=16)
19079 {
19080
2/2
✓ Branch 0 taken 1048080 times.
✓ Branch 1 taken 65505 times.
1113585 for(int32_t x=offx; x<offx+256; x+=16)
19081 {
19082
3/4
✓ Branch 0 taken 1048080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✓ Branch 3 taken 627025 times.
1048080 if(is_starting_pos(scr,i,x,y,0))
19083 {
19084
2/4
✓ Branch 0 taken 421055 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✗ Branch 3 not taken.
421055 freeposcache.push_back(COMBOPOS_REGION(x, y));
19085 421055 }
19086 1048080 }
19087 65505 }
19088
19089
2/2
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 11 times.
5955 if (!freeposcache.empty())
19090
1/2
✓ Branch 0 taken 5944 times.
✗ Branch 1 not taken.
5944 return freeposcache[zc_oldrand()%freeposcache.size()];
19091
19092 11 return rpos_t::None;
19093 5955 }
19094
19095 81129 void spawnEnemy(mapscr* scr, int& pos, int& clk, int offx, int offy, int& fastguys, int& i, int& guycnt, int& loadcnt)
19096 {
19097 81129 int screen = scr->screen;
19098 81129 int x = 0;
19099 81129 int y = 0;
19100 81129 bool placed=false;
19101 81129 int32_t t=-1;
19102
19103 // First: enemy combo flags
19104
2/2
✓ Branch 0 taken 805411 times.
✓ Branch 1 taken 63763 times.
869174 for(int32_t sy=0; sy<176; sy+=16)
19105 {
19106
2/2
✓ Branch 0 taken 12757413 times.
✓ Branch 1 taken 788045 times.
13545458 for(int32_t sx=0; sx<256; sx+=16)
19107 {
19108 12757413 x = offx + sx;
19109 12757413 y = offy + sy;
19110 12757413 int32_t cflag = MAPFLAG(x, y);
19111 12757413 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19112
19113
2/4
✓ Branch 0 taken 12757413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12757413 times.
✗ Branch 3 not taken.
12757413 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19114 {
19115 if(!ok2add(scr, scr->enemy[i]))
19116 {
19117 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19118 }
19119 else
19120 {
19121 addenemy_z(screen,x,
19122 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19123 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19124
19125 ++guycnt;
19126
19127 placed=true;
19128 goto placed_enemy;
19129 }
19130 }
19131
19132
4/4
✓ Branch 0 taken 12739998 times.
✓ Branch 1 taken 17415 times.
✓ Branch 2 taken 12739998 times.
✓ Branch 3 taken 17415 times.
12757413 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19133 {
19134
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17366 times.
17415 if(!ok2add(scr, scr->enemy[i]))
19135 {
19136
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19137 49 }
19138 else
19139 {
19140 34732 addenemy_z(screen,x,
19141
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17365 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17366 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19142
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17365 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17366 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19143
19144 17366 ++guycnt;
19145
19146 17366 placed=true;
19147 17366 goto placed_enemy;
19148 }
19149 49 }
19150 12740047 }
19151 788045 }
19152
19153 // Next: enemy pattern
19154
6/8
✓ Branch 0 taken 4997 times.
✓ Branch 1 taken 58766 times.
✓ Branch 2 taken 58029 times.
✓ Branch 3 taken 5734 times.
✓ Branch 4 taken 58029 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 58029 times.
63763 if((scr->pattern==pRANDOM || scr->pattern==pCEILING) && !(isSideViewGravity()) && ((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS)))
19155 {
19156 58029 do
19157 {
19158
19159 // NES positions
19160 99523 pos%=9;
19161 99523 x=offx+stx[loadside][pos];
19162 99523 y=offy+sty[loadside][pos];
19163 99523 ++pos;
19164 99523 ++t;
19165
2/2
✓ Branch 0 taken 41494 times.
✓ Branch 1 taken 58029 times.
157552 }
19166
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99302 times.
99523 while((t< 20) && !is_starting_pos(scr,i,x,y,t));
19167 58029 }
19168
19169
4/4
✓ Branch 0 taken 58029 times.
✓ Branch 1 taken 5734 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57808 times.
63763 if(t<0 || t >= 20) // above enemy pattern failed
19170 {
19171 // Final chance: find a random position anywhere onscreen
19172 5955 rpos_t rand_rpos = placeenemy(scr, i, offx, offy);
19173
19174
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5944 times.
5955 if (rand_rpos != rpos_t::None)
19175 {
19176 5944 std::tie(x, y) = COMBOXY_REGION(rand_rpos);
19177 5944 }
19178 else // All opportunities failed - abort
19179 {
19180 11 return;
19181 }
19182 5944 }
19183
19184 {
19185 63752 int32_t c=0;
19186 63752 c=clk;
19187
19188
2/2
✓ Branch 0 taken 9643 times.
✓ Branch 1 taken 54109 times.
63752 if(!slowguy(scr->enemy[i]))
19189 54109 ++fastguys;
19190
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 8057 times.
9643 else if(fastguys>0)
19191 1586 c=-15*(i-fastguys+2);
19192 else
19193 8057 c=-15*(i+1);
19194
19195
4/6
✓ Branch 0 taken 29160 times.
✓ Branch 1 taken 34592 times.
✓ Branch 2 taken 29160 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29160 times.
63752 if(BSZ&&((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19196 {
19197 // Special case for blue leevers
19198
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 27266 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
29160 if(guysbuf[scr->enemy[i]].family==eeLEV && guysbuf[scr->enemy[i]].attributes[0] == 1)
19199 761 c=-15*(i+1);
19200 else
19201 28399 c=-15;
19202 29160 }
19203
19204
2/2
✓ Branch 0 taken 62952 times.
✓ Branch 1 taken 800 times.
63752 if(!ok2add(scr, scr->enemy[i]))
19205 {
19206
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19207 800 }
19208 else
19209 {
19210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62952 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62952 if(((scr->enemy[i]>0||scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19211 {
19212
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62776 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
125904 addenemy_z(screen,x,(is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19213
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62776 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
62952 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],c);
19214
19215 62952 ++guycnt;
19216 62952 }
19217 }
19218
19219 63752 placed=true;
19220 63752 } // if(t < 20)
19221
19222 placed_enemy:
19223
19224 // I don't like this, but it seems to work...
19225 static bool foundCarrier;
19226
19227
2/2
✓ Branch 0 taken 59508 times.
✓ Branch 1 taken 21610 times.
81118 if(i==0)
19228 21610 foundCarrier=false;
19229
19230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81118 times.
81118 if(placed)
19231 {
19232
4/4
✓ Branch 0 taken 21610 times.
✓ Branch 1 taken 59508 times.
✓ Branch 2 taken 21441 times.
✓ Branch 3 taken 169 times.
81118 if(i==0 && scr->flags11&efLEADER)
19233 {
19234 169 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19235
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if (e)
19236 {
19237 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19238
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((e->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER))
19239 {
19240 e = find_guy_nth_for_id(screen, scr->enemy[i], 2, 0xFFF);
19241 }
19242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if (e)
19243 {
19244 162 e->leader = true;
19245 162 }
19246 162 }
19247 169 }
19248
19249 81118 ScreenItemState item_state = get_screen_state(screen).item_state;
19250
5/6
✓ Branch 0 taken 80876 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 80876 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✓ Branch 5 taken 80799 times.
81118 if (!foundCarrier && (item_state == ScreenItemState::CarriedByEnemy || item_state == ScreenItemState::MustGiveToEnemy))
19251 {
19252 77 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19253
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if (e && (e->flags&guy_doesnt_count)==0)
19254 {
19255 77 e->itemguy = true;
19256 77 foundCarrier=true;
19257 77 }
19258 77 }
19259 81118 }
19260 81129 }
19261
19262 // returns index of first sprite with matching id, -1 if none found
19263 246 enemy* find_guy_first_for_id(int screen, int id, int mask)
19264 {
19265 246 int count = guys.Count();
19266
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 7 times.
373 for (int32_t i=0; i<count; i++)
19267 {
19268 366 enemy* e = (enemy*)guys.spr(i);
19269
4/4
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 79 times.
366 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19270 {
19271 239 return e;
19272 }
19273 127 }
19274
19275 7 return nullptr;
19276 246 }
19277
19278 enemy* find_guy_nth_for_id(int screen, int id, int n, int mask)
19279 {
19280 int count = guys.Count();
19281 for(int32_t i=0; i<count; i++)
19282 {
19283 enemy* e = (enemy*)guys.spr(i);
19284 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19285 {
19286 if (n > 1) --n;
19287 else return e;
19288 }
19289 }
19290 return nullptr;
19291 }
19292
19293 bool scriptloadenemies(int screen)
19294 {
19295 if (sle_clk || script_sle[screen]) return false;
19296
19297 mapscr* scr = get_scr(screen);
19298 if(scr->pattern==pNOSPAWN) return false;
19299
19300 if(scr->pattern==pSIDES || scr->pattern==pSIDESR)
19301 {
19302 script_side_load_enemies(scr);
19303 return true;
19304 }
19305
19306 auto [x, y] = translate_screen_coordinates_to_world(screen);
19307 int32_t pos=zc_oldrand()%9;
19308 int32_t clk=-15,fastguys=0;
19309 int32_t i=0,guycnt=0;
19310 int32_t loadcnt = 10;
19311
19312 for(; i<loadcnt && scr->enemy[i]>0; i++)
19313 {
19314 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19315 spawnEnemy(scr, pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19316 if (guys.Count() > preguycount)
19317 {
19318 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19319 {
19320 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19321 {
19322 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19323 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19324 }
19325 }
19326 }
19327 --clk;
19328 }
19329 return true;
19330 }
19331
19332 14270415 void loadenemies()
19333 {
19334 28920988 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
19335 14650573 int screen = scr->screen;
19336 14650573 auto& state = get_screen_state(screen);
19337
2/2
✓ Branch 0 taken 14235345 times.
✓ Branch 1 taken 415228 times.
14650573 if (state.loaded_enemies)
19338 14235345 return;
19339
19340 // dungeon basements
19341 static byte dngn_enemy_x[4] = {32,96,144,208};
19342
2/2
✓ Branch 0 taken 148964 times.
✓ Branch 1 taken 266264 times.
415228 if (cur_screen>=128)
19343 {
19344
2/2
✓ Branch 0 taken 148489 times.
✓ Branch 1 taken 475 times.
148964 if(DMaps[cur_dmap].flags&dmfCAVES) return;
19345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[cur_dmap].flags&dmfNEWCELLARENEMIES )
19346 {
19347 for(int32_t i=0; i<10; i++)
19348 {
19349 if ( scr->enemy[i] )
19350 {
19351 int32_t preguycount = guys.Count();
19352 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i],-14-i);
19353 if (guys.Count() > preguycount)
19354 {
19355 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19356 {
19357 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19358 {
19359 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19360 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19361 }
19362 }
19363 }
19364 }
19365 }
19366 }
19367 else
19368 {
19369
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19370 {
19371 1900 int32_t preguycount = guys.Count();
19372
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i]?scr->enemy[i]:(int32_t)eKEESE1,-14-i);
19373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19374 {
19375
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19376 {
19377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19378 {
19379 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19380 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19381 4 }
19382 4 }
19383 1900 }
19384 1900 }
19385 }
19386
19387 475 state.loaded_enemies = true;
19388 475 return;
19389 }
19390
19391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266264 times.
266264 if (scr->pattern == pNOSPAWN)
19392 return;
19393
19394 // TODO: configure when screen enemies spawn.
19395
2/2
✓ Branch 0 taken 88972 times.
✓ Branch 1 taken 177292 times.
266264 if (!viewport.intersects_with(region_scr_x*256, region_scr_y*176, 256, 176))
19396 177292 return;
19397
19398
4/4
✓ Branch 0 taken 50525 times.
✓ Branch 1 taken 38447 times.
✓ Branch 2 taken 16069 times.
✓ Branch 3 taken 34456 times.
88972 if (scr->pattern==pSIDES || scr->pattern==pSIDESR)
19399 {
19400 54516 side_load_enemies(scr);
19401 54516 return;
19402 }
19403
19404 34456 state.loaded_enemies = true;
19405
19406 // check if it's the dungeon boss and it has been beaten before
19407
4/4
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 34098 times.
✓ Branch 2 taken 268 times.
✓ Branch 3 taken 90 times.
34456 if (scr->flags11&efBOSS && game->lvlitems[dlevel]&liBOSS)
19408 90 return;
19409
19410 34366 int32_t loadcnt = 10;
19411 34366 int16_t mi = mapind(cur_map, screen);
19412 34366 bool beenhere = check_if_recently_visited();
19413
19414 //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19415 34366 bool reload = true;
19416
4/4
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 24638 times.
✓ Branch 2 taken 4708 times.
✓ Branch 3 taken 5020 times.
34366 if (beenhere && game->guys[mi] == 0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19417 {
19418 5020 loadcnt = 0; //It will tell it not to load any enemies,
19419 5020 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19420 5020 }
19421
19422 34366 bool unbeatablereload = true;
19423
2/2
✓ Branch 0 taken 5020 times.
✓ Branch 1 taken 29346 times.
34366 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19424 {
19425 29346 loadcnt = game->guys[mi]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19426
19427
2/4
✓ Branch 0 taken 10289 times.
✓ Branch 1 taken 19057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29346 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10289 times.
10289 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19429 19057 loadcnt = 10; //That means all enemies need to be respawned.
19430
3/4
✓ Branch 0 taken 24638 times.
✓ Branch 1 taken 4708 times.
✓ Branch 2 taken 24638 times.
✗ Branch 3 not taken.
29346 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19431 {
19432 for(int32_t i = 0; i<loadcnt && scr->enemy[i]>0; i++)
19433 {
19434 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
19435 {
19436 unbeatablereload = false;
19437 }
19438 }
19439 if (unbeatablereload)
19440 {
19441 loadcnt = 10;
19442 }
19443 }
19444 29346 }
19445
19446
4/4
✓ Branch 0 taken 32905 times.
✓ Branch 1 taken 1461 times.
✓ Branch 2 taken 193 times.
✓ Branch 3 taken 32712 times.
34366 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19447 1654 loadcnt = 10; //All enemies also need to be respawned.
19448
19449 // do enemies that are always loaded
19450 34366 load_default_enemies(scr);
19451 34366 activate_fireball_statues(scr);
19452
19453 34366 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19454 34366 int32_t clk=-15,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
19455 34366 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19456
4/4
✓ Branch 0 taken 15162 times.
✓ Branch 1 taken 100333 times.
✓ Branch 2 taken 81129 times.
✓ Branch 3 taken 34366 times.
115495 for(; i<loadcnt && scr->enemy[i]>0; i++)
19457 {
19458 81129 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19459 81129 spawnEnemy(scr, pos, clk, region_scr_x*256, region_scr_y*176, fastguys, i, guycnt, loadcnt);
19460
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 80318 times.
81129 if (guys.Count() > preguycount)
19461 {
19462
2/2
✓ Branch 0 taken 77967 times.
✓ Branch 1 taken 2351 times.
80318 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19463 {
19464
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2347 times.
2351 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19465 {
19466 2347 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19467 2347 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19468 2347 }
19469 2351 }
19470 80318 }
19471
19472 81129 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19473 81129 }
19474
19475 34366 game->guys[mi] = guycnt;
19476 14650573 });
19477 14270415 }
19478
19479 233 void moneysign()
19480 {
19481 466 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
19482 466 additem(dx+48,dy+108,iRupy,ipDUMMY);
19483 233 set_clip_state(pricesdisplaybuf, 0);
19484 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19485 233 }
19486
19487 3304 void putprices(bool sign)
19488 {
19489
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3272 times.
3304 if(fadeclk > 0) return;
19490
19491 3272 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19492 3272 int32_t step=32;
19493 3272 int32_t x=80;
19494
19495
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2991 times.
3272 if(prices[2]==0)
19496 {
19497 2991 step<<=1;
19498
19499
2/2
✓ Branch 0 taken 2959 times.
✓ Branch 1 taken 32 times.
2991 if(prices[1]==0)
19500 {
19501 2959 x=112;
19502 2959 }
19503 2991 }
19504
19505
2/2
✓ Branch 0 taken 3272 times.
✓ Branch 1 taken 9816 times.
13088 for(int32_t i=0; i<3; i++)
19506 {
19507 // Kind of stupid, but it works: 100000 is used to indicate that an item
19508 // has a price of zero rather than there being no item.
19509 // 100000 isn't a valid price, so this doesn't cause problems.
19510
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8777 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9816 if(prices[i]!=0 && prices[i]<100000)
19511 {
19512 char buf[8];
19513 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19514
19515 1039 int32_t l=(int32_t)strlen(buf);
19516 1039 set_clip_state(pricesdisplaybuf, 0);
19517
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19518 1039 }
19519
19520 9816 x+=step;
19521 9816 }
19522 3304 }
19523
19524 // Setting up special rooms
19525 // Also called when the Letter is used successfully.
19526 1210 void setupscreen()
19527 {
19528 1210 boughtsomething=false;
19529
19530 // Either the origin screen, or if in a 0x80 room the screen player came from.
19531
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 794 times.
1210 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : origin_scr;
19532 1210 mapscr* scr = origin_scr;
19533
19534 1210 word str=base_scr->str;
19535
19536 2262 auto [dx, dy] = translate_screen_coordinates_to_world(scr->screen);
19537
19538 // Prices are already set to 0 in dowarp()
19539
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 689 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1210 switch(base_scr->room)
19540 {
19541 case rSP_ITEM: // special item
19542 328 additem(dx+120,dy+89,base_scr->catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19543 164 break;
19544
19545 case rINFO: // pay for info
19546 {
19547 28 int32_t count = 0;
19548 28 int32_t base = 88;
19549 28 int32_t step = 5;
19550
19551 28 moneysign();
19552
19553
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19554 {
19555
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[base_scr->catchall].str[i])
19556 {
19557 84 ++count;
19558 84 }
19559 else
19560 break;
19561 84 }
19562
19563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19564 {
19565
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19566 {
19567 base = 88+32;
19568 }
19569
19570
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19571 {
19572 step = 6;
19573 }
19574
19575
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19576 {
19577 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19578 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19579 84 prices[i] = -(QMisc.info[base_scr->catchall].price[i]);
19580
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19581 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19582 84 int32_t itemid = current_item_id(itype_wealthmedal);
19583
19584
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19585 {
19586 if(itemsbuf[itemid].flags & item_flag1)
19587 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19588 else
19589 prices[i]-=itemsbuf[itemid].misc1;
19590 prices[i]=vbound(prices[i], -99999, 0);
19591 if(prices[i]==0)
19592 prices[i]=100000;
19593 }
19594
19595
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[base_scr->catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19596 prices[i]=-1;
19597 84 }
19598 28 }
19599
19600 28 break;
19601 }
19602
19603 case rMONEY: // secret money
19604 88 additem(dx+120,dy+89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19605 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19606 44 break;
19607
19608 case rGAMBLE: // gambling
19609 11 prices[0]=prices[1]=prices[2]=-10;
19610 11 moneysign();
19611 22 additem(dx+88,dy+89,iRupy,ipMONEY+ipDUMMY);
19612 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19613 22 additem(dx+120,dy+89,iRupy,ipMONEY+ipDUMMY);
19614 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19615 22 additem(dx+152,dy+89,iRupy,ipMONEY+ipDUMMY);
19616 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19617 11 break;
19618
19619 case rREPAIR: // door repair
19620
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19621 // }
19622 13 repaircharge=base_scr->catchall;
19623 13 break;
19624
19625 case rMUPGRADE: // upgrade magic
19626 2 adjustmagic=true;
19627 2 break;
19628
19629 case rLEARNSLASH: // learn slash attack
19630 2 learnslash=true;
19631 2 break;
19632
19633 case rRP_HC: // heart container or red potion
19634 34 additem(dx+88,dy+89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19635 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19636 34 additem(dx+152,dy+89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19637 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19638 17 break;
19639
19640 case rP_SHOP: // potion shop
19641
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19642 {
19643 12 str=0;
19644 12 break;
19645 }
19646
19647 [[fallthrough]];
19648 case rTAKEONE: // take one
19649 case rSHOP: // shop
19650 {
19651 194 int32_t count = 0;
19652 194 int32_t base = 88;
19653 194 int32_t step = 5;
19654
19655
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(base_scr->room != rTAKEONE)
19656 193 moneysign();
19657
19658 //count and align the stuff
19659
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19660 {
19661
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[base_scr->catchall].hasitem[count] != 0)
19662 {
19663 523 ++count;
19664 523 }
19665 else
19666 {
19667 37 break;
19668 }
19669 523 }
19670
19671
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19672 {
19673 22 base = 88+32;
19674 22 }
19675
19676
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19677 {
19678 15 step = 6;
19679 15 }
19680
19681
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19682 {
19683 1046 additem(dx+(i<<step)+base, dy+89, QMisc.shop[base_scr->catchall].item[i], ipHOLDUP+ipFADE+(base_scr->room == rTAKEONE ? ipONETIME2 : ipCHECK));
19684 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19685
19686
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(base_scr->room != rTAKEONE)
19687 {
19688 521 prices[i] = QMisc.shop[base_scr->catchall].price[i];
19689
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19690 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19691 521 int32_t itemid = current_item_id(itype_wealthmedal);
19692
19693
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19694 {
19695
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19696 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19697 else
19698 prices[i]+=itemsbuf[itemid].misc1;
19699 9 prices[i]=vbound(prices[i], 0, 99999);
19700
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19701 prices[i]=100000;
19702 9 }
19703
19704
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[base_scr->catchall].price[i])>1 && prices[i]<1)
19705 prices[i]=1;
19706 521 }
19707 523 }
19708
19709 194 break;
19710 }
19711 case rBOTTLESHOP: // bottle shop
19712 {
19713 1 int32_t count = 0;
19714 1 int32_t base = 88;
19715 1 int32_t step = 5;
19716
19717 1 moneysign();
19718 1 bottleshoptype const& bst = QMisc.bottle_shop_types[base_scr->catchall];
19719 //count and align the stuff
19720
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19721 {
19722
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19723 {
19724 3 ++count;
19725 3 }
19726 else
19727 {
19728 break;
19729 }
19730 3 }
19731
19732
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19733 {
19734 base = 88+32;
19735 }
19736
19737
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19738 {
19739 step = 6;
19740 }
19741
19742
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19743 {
19744 6 adddummyitem(dx+(i<<step)+base, dy+89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19745 //{ Setup dummy item
19746 3 item* curItem = ((item*)items.spr(items.Count()-1));
19747 3 curItem->PriceIndex = i;
19748 3 newcombo const& cmb = combobuf[bst.comb[i]];
19749
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(cmb.animflags & AF_EDITOR_ONLY)
19750 {
19751 curItem->yofs = -32768;
19752 }
19753 3 curItem->o_tile = cmb.o_tile;
19754 3 curItem->o_cset = bst.cset[i];
19755 3 curItem->cs = curItem->o_cset;
19756 3 curItem->tile = cmb.o_tile;
19757 3 curItem->o_speed = cmb.speed;
19758 3 curItem->o_delay = 0;
19759 3 curItem->frames = cmb.frames;
19760 3 curItem->flip = cmb.flip;
19761 3 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
19762 3 curItem->pstring = 0;
19763 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19764 3 curItem->flash = false;
19765 3 curItem->twohand = false;
19766 3 curItem->anim = true;
19767 3 curItem->hit_width=1;
19768 3 curItem->hyofs=4;
19769 3 curItem->hit_height=12;
19770 3 curItem->script=0;
19771 3 curItem->txsz=1;
19772 3 curItem->tysz=1;
19773 //}
19774
19775 3 prices[i] = bst.price[i];
19776
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19777 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19778 3 int32_t itemid = current_item_id(itype_wealthmedal);
19779
19780
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19781 {
19782 if(itemsbuf[itemid].flags & item_flag1)
19783 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19784 else
19785 prices[i]+=itemsbuf[itemid].misc1;
19786 prices[i]=vbound(prices[i], 0, 99999);
19787 if(prices[i]==0)
19788 prices[i]=100000;
19789 }
19790
19791
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19792 prices[i]=1;
19793 3 }
19794
19795 1 break;
19796 }
19797
19798 case rBOMBS: // more bombs
19799 38 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19800 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19801 19 prices[0]=-base_scr->catchall;
19802 19 break;
19803
19804 case rARROWS: // more arrows
19805 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19806 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19807 prices[0]=-base_scr->catchall;
19808 break;
19809
19810 case rSWINDLE: // leave heart container or money
19811 28 additem(dx+88,dy+89,iHeartC,ipDUMMY+ipMONEY);
19812 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19813 14 prices[0]=-1;
19814 28 additem(dx+152,dy+89,iRupy,ipDUMMY+ipMONEY);
19815 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19816 14 prices[1]=-base_scr->catchall;
19817 14 break;
19818
19819 }
19820
19821
3/4
✓ Branch 0 taken 1191 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1191 times.
1210 if(base_scr->room == rBOMBS || base_scr->room == rARROWS)
19822 {
19823 19 int32_t i = (base_scr->room == rSWINDLE ? 1 : 0);
19824 19 int32_t itemid = current_item_id(itype_wealthmedal);
19825
19826
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19827 {
19828 if(itemsbuf[itemid].flags & item_flag1)
19829 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19830 else
19831 prices[i]+=itemsbuf[itemid].misc1;
19832 }
19833
19834
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(base_scr->catchall>1 && prices[i]>-1)
19835 prices[i]=-1;
19836 19 }
19837
19838 1210 putprices(false);
19839
19840
2/2
✓ Branch 0 taken 1151 times.
✓ Branch 1 taken 59 times.
1210 if(str)
19841 {
19842 1151 donewmsg(base_scr, str);
19843 1151 }
19844 else
19845 {
19846 59 Hero.unfreeze();
19847 }
19848 1210 }
19849
19850 enum
19851 {
19852 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
19853 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
19854
19855 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
19856
19857 MNU_DATA_MAX
19858 };
19859 struct menu_choice
19860 {
19861 int32_t x, y;
19862 int32_t pos;
19863 int32_t upos, dpos, lpos, rpos;
19864 18 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
19865 18 {}
19866 18 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
19867 int32_t dpos, int32_t lpos, int32_t rpos)
19868 18 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
19869 18 {}
19870 };
19871 static int32_t msg_menu_data[MNU_DATA_MAX];
19872 static bool do_run_menu = false;
19873 bool do_end_str = false;
19874 static bool wait_advance = false;
19875 411 static std::map<int32_t, menu_choice> menu_options;
19876 43880 void clr_msg_data()
19877 {
19878 43880 do_end_str = false;
19879 43880 wait_advance = false;
19880 43880 do_run_menu = false;
19881 43880 menu_options.clear();
19882 43880 memset(msg_menu_data, 0, sizeof(msg_menu_data));
19883 43880 }
19884
19885 static char namebuf[9] = {0};
19886 static char* nameptr = NULL;
19887 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
19888 2036 bool runMenuCursor()
19889 {
19890 2036 clear_bitmap(msg_menu_bmp_buf);
19891
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(!menu_options.size())
19892 {
19893 msg_menu_data[MNU_CHOSEN] = 0;
19894 return true; //end menu
19895 }
19896 2036 int32_t pos = msg_menu_data[MNU_CHOSEN];
19897 //If the cursor is at an invalid pos, find the first pos >= 0...
19898
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19899 {
19900 pos = 0;
19901 while(menu_options.find(pos) == menu_options.end())
19902 ++pos;
19903 }
19904 2036 menu_choice* ch = &menu_options[pos];
19905
19906 2036 bool pressed = true;
19907
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2032 times.
2036 if(rUp()) pos = ch->upos;
19908
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2030 times.
2032 else if(rDown()) pos = ch->dpos;
19909
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2021 times.
2030 else if(rLeft()) pos = ch->lpos;
19910
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2010 times.
2021 else if(rRight()) pos = ch->rpos;
19911 2010 else pressed = false;
19912
19913
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
2036 if(pressed)
19914 26 msg_menu_data[MNU_TIMER] = 1;
19915
19916 2036 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
19917 2036 bool held = false;
19918
2/2
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 90 times.
2036 if(hold_input)
19919 {
19920 90 held = true;
19921
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 89 times.
90 if(Up()) pos = ch->upos;
19922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Down()) pos = ch->dpos;
19923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Left()) pos = ch->lpos;
19924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Right()) pos = ch->rpos;
19925 89 else held = false;
19926 90 }
19927 //If the cursor is at an invalid pos, find the first pos >= 0...
19928
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19929 {
19930 pos = 0;
19931 while(menu_options.find(pos) == menu_options.end())
19932 ++pos;
19933 }
19934
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2009 times.
✓ Branch 3 taken 27 times.
2036 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
19935 27 sfx(MsgStrings[msgstr].sfx);
19936
19937 2036 ch = &menu_options[pos];
19938 4072 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
19939 2036 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
19940 2036 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
19941 2036 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
19942
19943 2036 msg_menu_data[MNU_CHOSEN] = pos;
19944
19945
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 603 times.
2036 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
19946 {
19947 603 rAbtn(); //Eat
19948
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 5 times.
603 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
19949 603 }
19950
19951
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2009 times.
2036 bool ret = (pressed || held) ? false : rAbtn();
19952 //Eat inputs
19953 2036 rUp(); rDown(); rLeft(); rRight(); rAbtn();
19954
19955
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 5 times.
2036 if(ret)
19956 5 menu_options.clear();
19957
19958 2036 return ret;
19959 //false if pos changed this frame; no confirming while moving the cursor!
19960 2036 }
19961
19962 840211 bool bottom_margin_clip()
19963 {
19964 892265 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
19965
2/2
✓ Branch 0 taken 788157 times.
✓ Branch 1 taken 52054 times.
840211 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
19966 }
19967
19968 void update_msgstr();
19969
19970 3293 static bool parsemsgcode(const StringCommand& command)
19971 {
19972 3293 auto& args = command.args;
19973 3293 int last_arg = 0;
19974
19975
18/38
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1280 times.
✓ Branch 3 taken 1644 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 11 times.
✓ Branch 14 taken 22 times.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 122 times.
✓ Branch 24 taken 28 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 5 times.
✓ Branch 29 taken 18 times.
✓ Branch 30 taken 5 times.
✓ Branch 31 taken 7 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
3293 switch (command.code)
19976 {
19977 case MSGC_NEWLINE:
19978 {
19979 1280 ssc_tile_hei = ssc_tile_hei_buf;
19980
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 2 times.
1280 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
19981 1280 ssc_tile_hei_buf = -1;
19982 1280 cursor_y += thei + MsgStrings[msgstr].vspace;
19983 1280 cursor_x=msg_margins[left];
19984 1280 return true;
19985 }
19986
19987 case MSGC_COLOUR:
19988 {
19989 1644 int32_t cset = args[0];
19990 1644 msgcolour = CSET(cset)+(args[1]);
19991 1644 return true;
19992 }
19993
19994 case MSGC_SHDCOLOR:
19995 {
19996 int32_t cset = args[0];
19997 msg_shdcol = CSET(cset)+args[1];
19998 return true;
19999 }
20000 case MSGC_SHDTYPE:
20001 {
20002 msg_shdtype = args[0];
20003 return true;
20004 }
20005
20006 case MSGC_SPEED:
20007 {
20008 56 msgspeed=args[0];
20009 56 return true;
20010 }
20011
20012 case MSGC_CTRUP:
20013 {
20014 int32_t a1 = args[0];
20015 int32_t a2 = args[1];
20016 game->change_counter(a2, a1);
20017 return true;
20018 }
20019
20020 case MSGC_CTRDN:
20021 {
20022 5 int32_t a1 = args[0];
20023 5 int32_t a2 = args[1];
20024 5 game->change_counter(-a2, a1);
20025 5 return true;
20026 }
20027
20028 case MSGC_CTRSET:
20029 {
20030 7 int32_t a1 = args[0];
20031 7 int32_t a2 = args[1];
20032 7 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20033 7 return true;
20034 }
20035
20036 case MSGC_CTRUPPC:
20037 case MSGC_CTRDNPC:
20038 case MSGC_CTRSETPC:
20039 {
20040 2 int32_t counter = args[0];
20041 2 int32_t amount = args[1];
20042 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20043
20044
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(command.code==MSGC_CTRDNPC)
20045 amount*=-1;
20046
20047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(command.code==MSGC_CTRSETPC)
20048 game->set_counter(amount, counter);
20049 else
20050 2 game->change_counter(amount, counter);
20051
20052 2 return true;
20053 }
20054
20055 case MSGC_GIVEITEM:
20056 {
20057 70 int32_t itemID = args[0];
20058
20059 70 getitem(itemID, true);
20060
2/4
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20061 {
20062 70 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20063 70 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20064 70 }
20065 70 return true;
20066 }
20067
20068
20069 case MSGC_WARP:
20070 {
20071 int32_t dmap = args[0];
20072 int32_t scrn = args[1];
20073 int32_t dx = args[2];
20074 int32_t dy = args[3];
20075 int32_t wfx = args[4];
20076 int32_t sfx = args[5];
20077 if(dx >= MAX_SCC_ARG) dx = -1;
20078 if(dy >= MAX_SCC_ARG) dy = -1;
20079 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20080 do_end_str = true;
20081 return true;
20082 }
20083
20084 case MSGC_SETSCREEND:
20085 {
20086 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20087 int32_t screen = args[1];
20088 int32_t reg = args[2];
20089 int32_t val = args[3];
20090 FFCore.set_screen_d(screen + dmap, reg, val);
20091 return true;
20092 }
20093 case MSGC_TAKEITEM:
20094 {
20095 11 int32_t itemID = args[0];
20096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( FFCore.doscript(ScriptType::Item, itemID) )
20097 {
20098 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20099 }
20100 11 takeitem(itemID);
20101
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_bwpn == itemID )
20102 {
20103 game->forced_bwpn = -1;
20104 } //not else if! -Z
20105
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_awpn == itemID )
20106 {
20107 game->forced_awpn = -1;
20108 }
20109
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_xwpn == itemID )
20110 {
20111 game->forced_xwpn = -1;
20112 } //not else if! -Z
20113
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_ywpn == itemID )
20114 {
20115 game->forced_ywpn = -1;
20116 }
20117 11 verifyBothWeapons();
20118 11 return true;
20119 }
20120
20121 case MSGC_SFX:
20122 {
20123 22 sfx(args[0],128);
20124 22 return true;
20125 }
20126
20127 case MSGC_MIDI:
20128 {
20129 7 int32_t music = args[0];
20130
20131
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20132 1 music_stop();
20133 else
20134 6 jukebox(music+(ZC_MIDI_COUNT-1));
20135
20136 7 return true;
20137 }
20138
20139 case MSGC_FONT:
20140 {
20141 int fontid = args[0];
20142 int oh = text_height(msgfont);
20143 msgfont = get_zc_font(fontid);
20144 int nh = text_height(msgfont);
20145 int mh = std::max(oh,nh);
20146 if(mh > ssc_tile_hei_buf)
20147 ssc_tile_hei_buf = mh;
20148 return true;
20149 }
20150 case MSGC_RUN_FRZ_GENSCR:
20151 {
20152 word scr_id = args[0];
20153 bool force_redraw = args[1]!=0;
20154 if(force_redraw)
20155 {
20156 update_msgstr();
20157 draw_screen();
20158 }
20159 FFCore.runGenericFrozenEngine(scr_id);
20160 return true;
20161 }
20162 case MSGC_DRAWTILE:
20163 {
20164 int32_t tl = args[0];
20165 int32_t cs = args[1];
20166 int32_t t_wid = args[2];
20167 int32_t t_hei = args[3];
20168 int32_t fl = args[4];
20169
20170 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20171 {
20172 ssc_tile_hei = ssc_tile_hei_buf;
20173 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20174 ssc_tile_hei_buf = -1;
20175 cursor_y += thei + MsgStrings[msgstr].vspace;
20176 if(bottom_margin_clip()) return true;
20177 cursor_x=msg_margins[left];
20178 }
20179
20180 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20181 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20182 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20183 return true;
20184 }
20185
20186 case MSGC_GOTOIFRAND:
20187 {
20188 1 int32_t odds = args[0];
20189
20190 1 last_arg = 1;
20191
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!odds || !(zc_oldrand()%odds))
20192 1 goto switched;
20193
20194 return true;
20195 }
20196
20197 case MSGC_GOTOIFGLOBAL:
20198 {
20199 int32_t arg = args[0];
20200 int32_t d = zc_min(7,arg);
20201 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20202 arg = args[1];
20203
20204 if(game->screen_d[s][d] >= arg)
20205 {
20206 last_arg = 2;
20207 goto switched;
20208 }
20209
20210 return true;
20211 }
20212
20213 case MSGC_CHANGEPORTRAIT:
20214 {
20215 return true; //not implemented
20216 }
20217
20218 case MSGC_GOTOIFCREEND:
20219 {
20220 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20221 int32_t screen = args[1];
20222 int32_t reg = args[2];
20223 int32_t val = args[3];
20224 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20225 {
20226 last_arg = 4;
20227 goto switched;
20228 }
20229 return true;
20230 }
20231
20232 case MSGC_GOTOIF:
20233 {
20234 122 int32_t it = args[0];
20235
20236
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20237 {
20238 35 last_arg = 1;
20239 35 goto switched;
20240 }
20241
20242 87 return true;
20243 }
20244
20245 case MSGC_GOTOIFCTR:
20246 {
20247
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(game->get_counter(args[0]) >= args[1])
20248 {
20249 14 last_arg = 2;
20250 14 goto switched;
20251 }
20252
20253 14 return true;
20254 }
20255
20256 case MSGC_GOTOIFCTRPC:
20257 {
20258 int32_t counter = args[0];
20259 int32_t amount = (int32_t)((args[1]/100)*game->get_maxcounter(counter));
20260
20261 if(game->get_counter(counter)>=amount)
20262 {
20263 last_arg = 2;
20264 goto switched;
20265 }
20266
20267 return true;
20268 }
20269
20270 case MSGC_GOTOIFTRICOUNT:
20271 {
20272 if(TriforceCount() >= args[0])
20273 {
20274 last_arg = 1;
20275 goto switched;
20276 }
20277
20278 return true;
20279 }
20280
20281 case MSGC_GOTOIFTRI:
20282 {
20283 int32_t lev = args[0];
20284
20285 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20286 {
20287 last_arg = 1;
20288 goto switched;
20289 }
20290
20291 return true;
20292 }
20293
20294 case MSGC_SETUPMENU:
20295 {
20296 5 msg_menu_data[MNU_CURSOR_TILE] = args[0];
20297 5 msg_menu_data[MNU_CURSOR_CSET] = args[1];
20298 5 msg_menu_data[MNU_CURSOR_WID] = args[2];
20299 5 msg_menu_data[MNU_CURSOR_HEI] = args[3];
20300 5 msg_menu_data[MNU_CURSOR_FLIP] = args[4];
20301 5 return true;
20302 }
20303
20304 case MSGC_MENUCHOICE:
20305 {
20306 18 int32_t pos = args[0];
20307 18 int32_t upos = args[1];
20308 18 int32_t dpos = args[2];
20309 18 int32_t lpos = args[3];
20310 18 int32_t rpos = args[4];
20311
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20312 {
20313 2 ssc_tile_hei = ssc_tile_hei_buf;
20314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20315 2 ssc_tile_hei_buf = -1;
20316 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20318 2 cursor_x=msg_margins[left];
20319 2 }
20320
20321 36 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20322 18 upos, dpos, lpos, rpos);
20323
20324
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20325 18 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20326 18 return true;
20327 }
20328
20329 case MSGC_RUNMENU:
20330 {
20331 5 msg_menu_data[MNU_CHOSEN] = 0;
20332 5 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(menu_options.size() < 1)
20334 return true;
20335 5 do_run_menu = true;
20336 5 return true;
20337 }
20338
20339 case MSGC_GOTOMENUCHOICE:
20340 {
20341 7 int32_t choice = args[0];
20342
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(msg_menu_data[MNU_CHOSEN] == choice)
20343 {
20344 5 last_arg = 1;
20345 5 goto switched;
20346 }
20347
20348 2 return true;
20349 }
20350
20351 case MSGC_ENDSTRING:
20352 {
20353 3 do_end_str = true;
20354 3 return true;
20355 }
20356 case MSGC_WAIT_ADVANCE:
20357 {
20358 wait_advance = true;
20359 linkedmsgclk = 51;
20360 return true;
20361 }
20362 case MSGC_TRIGSECRETS:
20363 {
20364 bool perm = args[0];
20365 trigger_secrets_for_screen(TriggerSource::SCC, msgscr, false);
20366 if(perm)
20367 setmapflag(msgscr, mSECRET);
20368 return true;
20369 }
20370 case MSGC_TRIG_CMB_COPYCAT:
20371 {
20372 int copy_id = args[0];
20373 if(copy_id == byte(copy_id))
20374 trig_copycat(copy_id);
20375 return true;
20376 }
20377 case MSGC_SETSCREENSTATE:
20378 {
20379 int32_t flag = args[0];
20380 if(unsigned(flag)>=mMAXIND)
20381 {
20382 Z_error("SCC 133: Flag %d is invalid\n", flag);
20383 return true;
20384 }
20385 bool state = args[1];
20386 if(state)
20387 setmapflag(msgscr, 1<<flag);
20388 else
20389 unsetmapflag(msgscr, 1<<flag, true);
20390 return true;
20391 }
20392 case MSGC_SETSCREENSTATER:
20393 {
20394 int32_t map = args[0];
20395 int32_t scrid = args[1];
20396 if(map < 1 || map > map_count)
20397 {
20398 Z_error("SCC 134: Map %d is invalid\n", map);
20399 return true;
20400 }
20401 if(unsigned(scrid)>=0x80)
20402 {
20403 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20404 return true;
20405 }
20406
20407 int32_t flag = args[2];
20408 if(unsigned(flag)>=mMAXIND)
20409 {
20410 Z_error("SCC 134: Flag %d is invalid\n", flag);
20411 return true;
20412 }
20413 bool state = args[3];
20414 if(state)
20415 setmapflag_mi(msgscr, mapind(map,scrid),1<<flag);
20416 else
20417 unsetmapflag_mi(msgscr, mapind(map,scrid),1<<flag,true);
20418 return true;
20419 }
20420 switched:
20421 55 int32_t lev = args[last_arg];
20422
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
55 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20423
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
54 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20424 {
20425 setmsg(lev);
20426 }
20427 else
20428 {
20429 55 donewmsg(msgscr, lev);
20430 55 ssc_tile_hei_buf = -1;
20431 }
20432 55 putprices(false);
20433 55 return true;
20434 }
20435
20436 return false;
20437 3293 }
20438
20439 3299 static std::string parsemsgcode2(const StringCommand& command)
20440 {
20441
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (command.code == MSGC_NAME)
20442 {
20443
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 return game->get_name();
20444 }
20445 else
20446 {
20447 3293 parsemsgcode(command);
20448 }
20449
20450
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 return "";
20451 3299 }
20452
20453 252746 static bool putmsgchar(bool play_sfx)
20454 {
20455 DCHECK(msg_it->state == MsgStr::iterator::CHARACTER);
20456 DCHECK(!msg_it->character.empty());
20457
20458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252746 times.
252746 if (bottom_margin_clip())
20459 return false;
20460
20461 // If the current word would overflow the margins, increment cursor to the next line.
20462 252746 const char* rem_word = msg_it->remaining_word();
20463 252746 int tlength = text_length(msgfont, rem_word) + ((int32_t)strlen(rem_word)*MsgStrings[msgstr].hspace);
20464
4/4
✓ Branch 0 taken 5672 times.
✓ Branch 1 taken 247074 times.
✓ Branch 2 taken 499 times.
✓ Branch 3 taken 5081 times.
258326 if (cursor_x+tlength > (msg_w-msg_margins[right]) &&
20465
4/4
✓ Branch 0 taken 5580 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 5081 times.
✓ Branch 3 taken 92 times.
5672 ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) ? true : strcmp(rem_word," ")!=0))
20466 {
20467 5580 ssc_tile_hei = ssc_tile_hei_buf;
20468
1/2
✓ Branch 0 taken 5580 times.
✗ Branch 1 not taken.
5580 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20469 5580 ssc_tile_hei_buf = -1;
20470 5580 cursor_y += thei + MsgStrings[msgstr].vspace;
20471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5580 times.
5580 if (bottom_margin_clip()) return false;
20472
20473 5580 cursor_x = msg_margins[left];
20474 5580 }
20475
20476
2/2
✓ Branch 0 taken 34959 times.
✓ Branch 1 taken 217787 times.
252746 if (play_sfx)
20477 217787 sfx(MsgStrings[msgstr].sfx);
20478
20479 // Print the character (unless it's just a space).
20480
2/2
✓ Branch 0 taken 59011 times.
✓ Branch 1 taken 193735 times.
252746 if (msg_it->character != " ")
20481 193735 textout_styled_aligned_ex(msg_txt_bmp_buf, msgfont, msg_it->character.c_str(), cursor_x, cursor_y, msg_shdtype, sstaLEFT, msgcolour, msg_shdcol, -1);
20482
20483 // Move the cursor.
20484 252746 cursor_x += msgfont->vtable->text_length(msgfont, msg_it->character.c_str());
20485
2/2
✓ Branch 0 taken 59011 times.
✓ Branch 1 taken 193735 times.
252746 if (msg_it->character != " ")
20486 193735 cursor_x += MsgStrings[msgstr].hspace;
20487
20488 252746 return true;
20489 252746 }
20490
20491 enum msg_tick_result {msg_tick_exit, msg_tick_break, msg_tick_continue};
20492
20493 static void msg_tick_end(bool disappear = false);
20494 241804 static msg_tick_result msg_tick(bool play_sfx, bool burst_mode)
20495 {
20496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241804 times.
241804 if (msg_it->done())
20497 return msg_tick_exit;
20498
20499
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 239773 times.
241804 if (!do_run_menu)
20500 {
20501
4/4
✓ Branch 0 taken 239773 times.
✓ Branch 1 taken 3299 times.
✓ Branch 2 taken 3299 times.
✓ Branch 3 taken 239773 times.
243072 while (msg_it->state == MsgStr::iterator::COMMAND && !do_run_menu)
20502 {
20503 3299 bool one_frame_command_delay = !replay_version_check(41);
20504 3299 std::string text = parsemsgcode2(msg_it->command);
20505
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (text.empty())
20506 {
20507
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3293 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3293 times.
3293 msg_it->set_buffer("");
20508 // Advance the iterator to run many commands in one frame.
20509
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 3169 times.
3293 if (!one_frame_command_delay)
20510
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 msg_it->next();
20511 3293 }
20512 else
20513 {
20514
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 msg_it->set_buffer(text);
20515
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 msg_it->next();
20516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (one_frame_command_delay)
20517 6 msg_it->post_segment_delay = 1;
20518 }
20519 3299 }
20520
20521
2/2
✓ Branch 0 taken 3177 times.
✓ Branch 1 taken 236596 times.
239773 if (msg_it->state == MsgStr::iterator::CHARACTER)
20522 {
20523
1/2
✓ Branch 0 taken 236596 times.
✗ Branch 1 not taken.
236596 if (!putmsgchar(play_sfx)) return msg_tick_break;
20524 236596 }
20525 239773 }
20526
20527 241804 bool wait_advance_check_early = !burst_mode;
20528
20529
2/2
✓ Branch 0 taken 78489 times.
✓ Branch 1 taken 163315 times.
241804 if (wait_advance_check_early)
20530 {
20531
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 163314 times.
163315 if (do_end_str)
20532 {
20533 1 msg_tick_end();
20534 1 return msg_tick_exit;
20535 }
20536
20537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163314 times.
163314 if (wait_advance)
20538 {
20539 msg_it->next();
20540 return msg_tick_exit;
20541 }
20542 163314 }
20543
20544
2/2
✓ Branch 0 taken 239767 times.
✓ Branch 1 taken 2036 times.
241803 if (do_run_menu)
20545 {
20546
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2031 times.
2036 if (runMenuCursor())
20547 {
20548 5 do_run_menu = false;
20549
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!burst_mode)
20550 {
20551 2 msg_it->next();
20552 2 return msg_tick(play_sfx, burst_mode);
20553 }
20554 3 }
20555 2031 else return msg_tick_break;
20556 3 }
20557
20558 239770 msg_it->next();
20559
20560
2/2
✓ Branch 0 taken 161815 times.
✓ Branch 1 taken 77955 times.
239770 if (!wait_advance_check_early)
20561 {
20562
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77953 times.
77955 if (do_end_str)
20563 {
20564 2 msg_tick_end();
20565 2 return msg_tick_exit;
20566 }
20567
20568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77953 times.
77953 if (wait_advance)
20569 return msg_tick_exit;
20570 77953 }
20571
20572
4/4
✓ Branch 0 taken 4008 times.
✓ Branch 1 taken 235760 times.
✓ Branch 2 taken 1990 times.
✓ Branch 3 taken 2018 times.
239768 if (msg_it->done() && MsgStrings[msgstr].nextstring)
20573 {
20574
1/2
✓ Branch 0 taken 2018 times.
✗ Branch 1 not taken.
2018 if (MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20575 setmsg(MsgStrings[msgstr].nextstring);
20576 2018 }
20577
20578 239768 return msg_tick_continue;
20579 241804 }
20580
20581 165602 static void msg_tick_end(bool disappear)
20582 {
20583
2/2
✓ Branch 0 taken 164589 times.
✓ Branch 1 taken 1013 times.
165602 if (disappear)
20584 1013 goto disappear;
20585
20586 // Done printing the string
20587
8/8
✓ Branch 0 taken 164586 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 163089 times.
✓ Branch 3 taken 1497 times.
✓ Branch 4 taken 159062 times.
✓ Branch 5 taken 4027 times.
✓ Branch 6 taken 159062 times.
✓ Branch 7 taken 4027 times.
164589 if (do_end_str || !do_run_menu && (msg_it->done() || bottom_margin_clip()) && !linkedmsgclk)
20588 {
20589
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4027 times.
4030 if(!do_end_str)
20590 {
20591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4027 times.
4027 while (msg_it->state == MsgStr::iterator::COMMAND)
20592 {
20593 parsemsgcode2(msg_it->command);
20594 msg_it->next();
20595 }
20596 4027 }
20597
20598 // Go to next string, or make it disappear by going to string 0.
20599
5/6
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 2020 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 1014 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 996 times.
4030 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
20600 {
20601 3034 linkedmsgclk=do_end_str?1:51;
20602 3034 }
20603
20604
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 2020 times.
4030 if(MsgStrings[msgstr].nextstring==0)
20605 {
20606
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 996 times.
2010 if(!get_qr(qr_MSGDISAPPEAR))
20607 996 {
20608 disappear:
20609 2009 msg_active = false;
20610 2009 Hero.finishedmsg();
20611 2009 }
20612
20613
2/2
✓ Branch 0 taken 3010 times.
✓ Branch 1 taken 13 times.
3023 if(repaircharge)
20614 {
20615
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 game->change_drupy(-(cur_screen >= 128 ? special_warp_return_scr : msgscr)->catchall);
20616 13 repaircharge = 0;
20617 13 }
20618
20619
2/2
✓ Branch 0 taken 3021 times.
✓ Branch 1 taken 2 times.
3023 if(adjustmagic)
20620 {
20621
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
20622 {
20623
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->get_magicdrainrate())
20624 2 game->set_magicdrainrate(1);
20625 2 }
20626 else if(game->get_magicdrainrate() > 1)
20627 {
20628 game->set_magicdrainrate(game->get_magicdrainrate()/2);
20629 }
20630 2 adjustmagic = false;
20631 2 sfx(WAV_SCALE);
20632
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20633 2 }
20634
20635
2/2
✓ Branch 0 taken 3021 times.
✓ Branch 1 taken 2 times.
3023 if(learnslash)
20636 {
20637 2 game->set_canslash(1);
20638 2 learnslash = false;
20639 2 sfx(WAV_SCALE);
20640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20641 2 }
20642 3023 }
20643 5043 }
20644 165602 }
20645
20646 6229 static void msg_consume_spaces()
20647 {
20648
2/2
✓ Branch 0 taken 6229 times.
✓ Branch 1 taken 16150 times.
22379 while (msg_it->character == " ")
20649 {
20650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16150 times.
16150 if (!putmsgchar(false)) break;
20651
20652 // Advance the iterator.
20653 16150 msg_it->next();
20654
20655 // The "Continue From Previous" feature
20656
1/2
✓ Branch 0 taken 16150 times.
✗ Branch 1 not taken.
16150 if (msg_it->state == MsgStr::iterator::DONE)
20657 {
20658 if(MsgStrings[msgstr].nextstring)
20659 {
20660 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20661 {
20662 setmsg(MsgStrings[msgstr].nextstring);
20663 }
20664 }
20665 }
20666 }
20667 6229 }
20668
20669 14621309 void putmsg()
20670 {
20671
2/2
✓ Branch 0 taken 681999 times.
✓ Branch 1 taken 13939310 times.
14621309 if(!msgorig) msgorig=msgstr;
20672
20673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14621309 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14621309 if(wait_advance && linkedmsgclk < 1)
20674 linkedmsgclk = 1;
20675
2/2
✓ Branch 0 taken 14342925 times.
✓ Branch 1 taken 278384 times.
14621309 if(linkedmsgclk>0)
20676 {
20677
2/2
✓ Branch 0 taken 126883 times.
✓ Branch 1 taken 151501 times.
278384 if(linkedmsgclk==1)
20678 {
20679
6/6
✓ Branch 0 taken 126880 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 123969 times.
✓ Branch 3 taken 2911 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 123851 times.
126883 if(do_end_str||cAbtn()||cBbtn())
20680 {
20681 3032 do_end_str = false;
20682 3032 linkedmsgclk = 0;
20683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3032 times.
3032 if(wait_advance)
20684 {
20685 wait_advance = false;
20686 }
20687 else
20688 {
20689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3032 times.
3032 if (!msgscr) msgscr = hero_scr;
20690 3032 msgstr=MsgStrings[msgstr].nextstring;
20691 3032 ssc_tile_hei_buf = -1;
20692
3/4
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 1013 times.
✗ Branch 3 not taken.
3032 if(!msgstr && enqueued_str)
20693 {
20694 msgstr = enqueued_str;
20695 enqueued_str = 0;
20696 }
20697
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2019 times.
3032 if(!msgstr)
20698 {
20699 1013 msgfont=get_zc_font(font_zfont);
20700
20701
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1009 times.
1013 if(msgscr->room!=rGRUMBLE)
20702 1009 blockpath=false;
20703
20704 1013 dismissmsg();
20705 1013 msg_tick_end(true);
20706 1013 return;
20707 }
20708
20709 2019 donewmsg(msgscr, msgstr);
20710 2019 putprices(false);
20711 }
20712 2019 }
20713 125870 }
20714 else
20715 {
20716 151501 --linkedmsgclk;
20717 }
20718 277371 }
20719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14620296 times.
14620296 if(wait_advance) return; //Waiting for buttonpress
20720
20721
9/10
✓ Branch 0 taken 14618347 times.
✓ Branch 1 taken 1949 times.
✓ Branch 2 taken 677074 times.
✓ Branch 3 taken 13941273 times.
✓ Branch 4 taken 263534 times.
✓ Branch 5 taken 413540 times.
✓ Branch 6 taken 259508 times.
✓ Branch 7 taken 4026 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 259508 times.
14620296 if(!do_run_menu && (!msgstr || !msg_it || msg_it->done() || bottom_margin_clip()))
20722 {
20723
2/2
✓ Branch 0 taken 13941273 times.
✓ Branch 1 taken 417566 times.
14358839 if(!msgstr)
20724 13941273 msgorig=0;
20725
20726 14358839 msg_active = false;
20727 14358839 msg_it.reset();
20728 14358839 return;
20729 }
20730
20731
1/2
✓ Branch 0 taken 261457 times.
✗ Branch 1 not taken.
261457 if (!msg_it)
20732 return;
20733
20734 261457 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20735
20736
2/2
✓ Branch 0 taken 257407 times.
✓ Branch 1 taken 4050 times.
261457 if (msg_it->state == MsgStr::iterator::NOT_STARTED)
20737 {
20738 4050 msg_it->next();
20739 4050 msg_consume_spaces();
20740 4050 }
20741
20742 // If the player is holding down the B button, or if msgspeed is 0, process as many characters
20743 // as possible. This skips the character-by-character animation that usually renders a string
20744 // slowly over many frames.
20745
4/4
✓ Branch 0 taken 1381 times.
✓ Branch 1 taken 260076 times.
✓ Branch 2 taken 891 times.
✓ Branch 3 taken 259185 times.
261457 if ((cBbtn() && get_qr(qr_ALLOWMSGBYPASS)) || msgspeed == 0)
20746 {
20747
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 78499 times.
80225 while (!msg_it->done())
20748 {
20749
5/6
✓ Branch 0 taken 20654 times.
✓ Branch 1 taken 57845 times.
✓ Branch 2 taken 20644 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 20644 times.
✗ Branch 5 not taken.
78499 if (msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20750 10 goto breakout; // break out if message speed was changed to non-zero
20751
20752 78489 auto tick = msg_tick(msg_it->character != " ", true);
20753
2/2
✓ Branch 0 taken 77955 times.
✓ Branch 1 taken 534 times.
78489 if (tick == msg_tick_break)
20754 534 break;
20755
2/2
✓ Branch 0 taken 77953 times.
✓ Branch 1 taken 2 times.
77955 if (tick == msg_tick_exit)
20756 2 return;
20757 }
20758
20759
2/2
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 1274 times.
1808 if (!do_run_menu)
20760 {
20761 1274 msgclk = 72;
20762 1274 }
20763 1808 }
20764 else
20765 259185 {
20766 breakout:
20767 259195 word tempspeed = msgspeed;
20768
2/2
✓ Branch 0 taken 258232 times.
✓ Branch 1 taken 963 times.
259195 if (do_run_menu)
20769 963 tempspeed = 0;
20770
6/6
✓ Branch 0 taken 207919 times.
✓ Branch 1 taken 51276 times.
✓ Branch 2 taken 121580 times.
✓ Branch 3 taken 86339 times.
✓ Branch 4 taken 111503 times.
✓ Branch 5 taken 10077 times.
259195 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20771 96416 return;
20772 }
20773
20774 // Process the next msg tick.
20775 // This will either print a single character, or process a single string command (with one
20776 // exception).
20777
3/4
✓ Branch 0 taken 163313 times.
✓ Branch 1 taken 1274 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163313 times.
164587 if (!msg_it->done() && !bottom_margin_clip())
20778 {
20779 // This may run an additional tick in the case of a string menu finishing: the first
20780 // tick wraps up the menu, and then a second tick processes the next character or command.
20781 163313 auto tick = msg_tick(true, false);
20782
2/2
✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 161816 times.
163313 if (tick == msg_tick_break)
20783 {
20784 1497 msg_tick_end();
20785 1497 return;
20786 }
20787
2/2
✓ Branch 0 taken 161815 times.
✓ Branch 1 taken 1 times.
161816 if (tick == msg_tick_exit)
20788 1 return;
20789
20790 // If the next two characters are spaces, consume all upcoming spaces now.
20791
13/20
✓ Branch 0 taken 2753 times.
✓ Branch 1 taken 159062 times.
✓ Branch 2 taken 159062 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26256 times.
✓ Branch 5 taken 132806 times.
✓ Branch 6 taken 26256 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 26256 times.
✓ Branch 10 taken 135559 times.
✓ Branch 11 taken 26256 times.
✓ Branch 12 taken 2753 times.
✓ Branch 13 taken 159062 times.
✓ Branch 14 taken 159636 times.
✓ Branch 15 taken 2179 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
188071 if (!msg_it->done() && msg_it->peek(0) == " " && msg_it->peek(1) == " ")
20792 2179 msg_consume_spaces();
20793 161815 }
20794
20795 163089 msg_tick_end();
20796 14620857 }
20797
20798 124886 int32_t message_more_y()
20799 {
20800 //Is the flag ticked, do we really want a message more y larger than 160?
20801
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124858 times.
✓ Branch 2 taken 124886 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124858 times.
✓ Branch 5 taken 28 times.
124886 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
20802 124886 msgy+=playing_field_offset;
20803 124886 return msgy;
20804 }
20805
20806 /*** Collision detection & handling ***/
20807
20808 14309072 void clear_script_one_frame_conditions()
20809 {
20810
2/2
✓ Branch 0 taken 38989033 times.
✓ Branch 1 taken 14309072 times.
53298105 for(int32_t j=0; j<guys.Count(); j++)
20811 {
20812 38989033 enemy *e = (enemy*)guys.spr(j);
20813
2/2
✓ Branch 0 taken 662813561 times.
✓ Branch 1 taken 38989033 times.
701802594 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
20814 38989033 }
20815 14309072 }
20816
20817 4882029 void check_enemy_lweapon_collision(weapon *w)
20818 {
20819
8/8
✓ Branch 0 taken 4265933 times.
✓ Branch 1 taken 616096 times.
✓ Branch 2 taken 3270388 times.
✓ Branch 3 taken 995545 times.
✓ Branch 4 taken 3208246 times.
✓ Branch 5 taken 62142 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3191508 times.
4882029 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
20820 {
20821
2/2
✓ Branch 0 taken 3175694 times.
✓ Branch 1 taken 11214136 times.
14389830 for(int32_t j=0; j<guys.Count(); j++)
20822 {
20823 11214136 enemy *e = (enemy*)guys.spr(j);
20824
20825 11214136 bool didhit = e->hit(w);
20826 //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
20827 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
20828
2/2
✓ Branch 0 taken 10993295 times.
✓ Branch 1 taken 220841 times.
11214136 if(didhit)
20829 {
20830 // !(e->stunclk)
20831 220841 int32_t h = e->takehit(w);
20832
2/2
✓ Branch 0 taken 186965 times.
✓ Branch 1 taken 33876 times.
220841 if (h < 0) // hitby code
20833 {
20834 33876 int indx = Lwpns.find(w);
20835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33876 times.
33876 if(indx > -1)
20836 33876 e->hitby[HIT_BY_LWEAPON] = indx+1;
20837 33876 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
20838 33876 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
20839
2/2
✓ Branch 0 taken 31471 times.
✓ Branch 1 taken 2405 times.
33876 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
20840 2405 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
20841 33876 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
20842 33876 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
20843 //we may need to handle this in special cases. -Z
20844 // arrow item pierce flag, for example -Em
20845 33876 }
20846
20847
2/2
✓ Branch 0 taken 33876 times.
✓ Branch 1 taken 186965 times.
220841 if(h < 0) // hit, check if weapon is "out of pierces"
20848 33876 w->hit_pierce(e, h);
20849
2/2
✓ Branch 0 taken 176556 times.
✓ Branch 1 taken 10409 times.
186965 else if(h > 0) // blocked
20850 10409 w->onhit(false, e, h);
20851
2/2
✓ Branch 0 taken 218167 times.
✓ Branch 1 taken 2674 times.
220841 if(abs(h) == 2)
20852 2674 break; // some enemy classes force a weapon hitting them to "wait a frame"
20853 218167 }
20854
20855
2/2
✓ Branch 0 taken 11198322 times.
✓ Branch 1 taken 13140 times.
11211462 if(w->Dead())
20856 {
20857 13140 break;
20858 }
20859 11198322 }
20860
20861 // Item flags added in 2.55:
20862 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
20863 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
20864 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
20865 // -Em
20866
6/6
✓ Branch 0 taken 2736671 times.
✓ Branch 1 taken 454837 times.
✓ Branch 2 taken 2691985 times.
✓ Branch 3 taken 44686 times.
✓ Branch 4 taken 44121 times.
✓ Branch 5 taken 2647864 times.
3191508 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
20867 {
20868 543644 int32_t itype, pitem = w->parentitem;
20869
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 454837 times.
✓ Branch 2 taken 44121 times.
✓ Branch 3 taken 44686 times.
543644 switch(w->id)
20870 {
20871 454837 case wBrang: itype = itype_brang; break;
20872 44121 case wArrow: itype = itype_arrow; break;
20873 case wHookshot:
20874 44686 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
20875 44686 break;
20876 }
20877
2/2
✓ Branch 0 taken 538603 times.
✓ Branch 1 taken 5041 times.
543644 if(pitem < 0) pitem = current_item_id(itype);
20878
5/6
✓ Branch 0 taken 44686 times.
✓ Branch 1 taken 498958 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44586 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
543644 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
20879 { //Swap with item
20880 for(int32_t j=0; j<items.Count(); j++)
20881 {
20882 if(items.spr(j)->hit(w))
20883 {
20884 item *theItem = ((item*)items.spr(j));
20885 bool priced = theItem->PriceIndex >-1;
20886 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
20887 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20888 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20889 {
20890 if(!Hero.switchhookclk)
20891 {
20892 hooked_comborpos = rpos_t::None;
20893 hooked_layerbits = 0;
20894 switching_object = theItem;
20895 theItem->switch_hooked = true;
20896 w->misc = 2;
20897 w->step = 0;
20898 theItem->clk2=256;
20899 Hero.doSwitchHook(game->get_switchhookstyle());
20900 if(QMisc.miscsfx[sfxSWITCHED])
20901 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
20902 }
20903 }
20904 }
20905 }
20906 }
20907
6/6
✓ Branch 0 taken 44121 times.
✓ Branch 1 taken 499523 times.
✓ Branch 2 taken 374622 times.
✓ Branch 3 taken 330501 times.
✓ Branch 4 taken 499523 times.
✓ Branch 5 taken 330501 times.
543644 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
20908 {
20909
2/2
✓ Branch 0 taken 88856 times.
✓ Branch 1 taken 374622 times.
463478 for(int32_t j=0; j<items.Count(); j++)
20910 {
20911
2/2
✓ Branch 0 taken 83962 times.
✓ Branch 1 taken 4894 times.
88856 if(items.spr(j)->hit(w))
20912 {
20913 4894 item *theItem = ((item*)items.spr(j));
20914 4894 bool priced = theItem->PriceIndex >-1;
20915
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4762 times.
4894 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
20916
5/8
✓ Branch 0 taken 4894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4894 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1105 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6959 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20917
4/6
✓ Branch 0 taken 3170 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3170 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3170 times.
4894 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
20918 {
20919
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
20920 {
20921 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
20922 }
20923
20924 1724 Hero.checkitems(j);
20925 1724 }
20926 4894 }
20927 88856 }
20928 374622 }
20929
2/2
✓ Branch 0 taken 15347 times.
✓ Branch 1 taken 153675 times.
830024 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
20930 {
20931
2/2
✓ Branch 0 taken 37008 times.
✓ Branch 1 taken 153675 times.
190683 for(int32_t j=0; j<items.Count(); j++)
20932 {
20933
2/2
✓ Branch 0 taken 28320 times.
✓ Branch 1 taken 8688 times.
37008 if(items.spr(j)->hit(w))
20934 {
20935 8688 item *theItem = ((item*)items.spr(j));
20936 8688 bool priced = theItem->PriceIndex >-1;
20937
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
20938
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20939
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20940 {
20941 7273 int32_t pickup = theItem->pickup;
20942 7273 int32_t id2 = theItem->id;
20943 7273 int32_t pstr = theItem->pstring;
20944 7273 int32_t pstr_flags = theItem->pickup_string_flags;
20945
20946 7273 std::vector<int32_t> &ev = FFCore.eventData;
20947 7273 ev.clear();
20948 7273 ev.push_back(id2*10000);
20949 7273 ev.push_back(pickup*10000);
20950 7273 ev.push_back(pstr*10000);
20951 7273 ev.push_back(pstr_flags*10000);
20952 7273 ev.push_back(0);
20953 7273 ev.push_back(theItem->getUID());
20954 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
20955 7273 ev.push_back(w->getUID());
20956
20957 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
20958 7273 bool nullify = ev[4] != 0;
20959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
20960
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
20961 {
20962 6197 w->onhit(false);
20963 6197 }
20964
20965
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
20966 {
20967 498 w->dead=1;
20968 498 theItem->clk2=256;
20969 498 w->dragging=j;
20970 498 theItem->is_dragged = true;
20971 498 }
20972 7273 }
20973 8688 }
20974 37008 }
20975 153675 }
20976 543644 }
20977 3191508 }
20978 4882029 }
20979 14306881 void check_collisions()
20980 {
20981
2/2
✓ Branch 0 taken 4881994 times.
✓ Branch 1 taken 14306881 times.
19188875 for(uint q = 0; q < Lwpns.Count(); ++q)
20982 4881994 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
20983 14306881 }
20984
20985 14309072 void dragging_item()
20986 {
20987
2/2
✓ Branch 0 taken 4998576 times.
✓ Branch 1 taken 14309072 times.
19307648 for(int32_t i=0; i<Lwpns.Count(); i++)
20988 {
20989 4998576 weapon *w = (weapon*)Lwpns.spr(i);
20990
20991
4/4
✓ Branch 0 taken 4535135 times.
✓ Branch 1 taken 463441 times.
✓ Branch 2 taken 4842911 times.
✓ Branch 3 taken 155665 times.
4998576 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
20992 {
20993
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148418 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155665 if(w->dragging>=0 && w->dragging<items.Count())
20994 {
20995 7247 item* dragItem = (item*)items.spr(w->dragging);
20996 7247 dragItem->x=w->x;
20997 7247 dragItem->y=w->y;
20998
20999 // Drag the Fairy enemy as well as the Fairy item
21000 7247 int32_t id = dragItem->id;
21001
21002
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21003 {
21004 404 movefairynew2(w->x,w->y,*dragItem);
21005 404 }
21006 7247 }
21007 155665 }
21008 4998576 }
21009 14309072 }
21010
21011 57 int32_t more_carried_items(int screen)
21012 {
21013 57 int32_t hasmorecarries = 0;
21014
21015
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 57 times.
121 for(int32_t i=0; i<items.Count(); i++)
21016 {
21017 64 auto spr = (item*)items.spr(i);
21018
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 57 times.
64 if (spr->screen_spawned == screen && (spr->pickup & ipENEMY))
21019 {
21020 57 hasmorecarries++;
21021 57 }
21022 64 }
21023
21024 57 return hasmorecarries;
21025 }
21026
21027 36535 static int count_guys_from_screen(int screen)
21028 {
21029 36535 int count = 0;
21030
2/2
✓ Branch 0 taken 237871 times.
✓ Branch 1 taken 36535 times.
274406 for (int i=0; i < guys.Count(); i++)
21031 {
21032
2/2
✓ Branch 0 taken 36538 times.
✓ Branch 1 taken 201333 times.
237871 if (((enemy*)guys.spr(i))->screen_spawned == screen)
21033 201333 count += 1;
21034 237871 }
21035 36535 return count;
21036 }
21037
21038 // messy code to do the enemy-carrying-the-item thing
21039 14697000 static void roaming_item(mapscr* scr)
21040 {
21041 14697000 int screen = scr->screen;
21042 14697000 auto& state = get_screen_state(screen);
21043
4/4
✓ Branch 0 taken 14660527 times.
✓ Branch 1 taken 36473 times.
✓ Branch 2 taken 14660465 times.
✓ Branch 3 taken 36535 times.
14697000 if (!(state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::MustGiveToEnemy) || !state.loaded_enemies)
21044 14660465 return;
21045
21046 // All enemies already dead upon entering a room?
21047
1/2
✓ Branch 0 taken 36535 times.
✗ Branch 1 not taken.
36535 if (count_guys_from_screen(screen) == 0)
21048 {
21049 return;
21050 }
21051
21052 36535 int guycarryingitem = -1;
21053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84544 times.
84544 for(int32_t j=0; j<guys.Count(); j++)
21054 {
21055 84544 enemy* e = (enemy*)guys.spr(j);
21056
4/4
✓ Branch 0 taken 62850 times.
✓ Branch 1 taken 21694 times.
✓ Branch 2 taken 26315 times.
✓ Branch 3 taken 36535 times.
84544 if (e->screen_spawned == screen && e->itemguy)
21057 {
21058 36535 guycarryingitem=j;
21059 36535 break;
21060 }
21061 48009 }
21062
21063
2/2
✓ Branch 0 taken 36458 times.
✓ Branch 1 taken 77 times.
36535 if (state.item_state == ScreenItemState::MustGiveToEnemy)
21064 {
21065
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(guycarryingitem == -1) //This happens when "default enemies" such as
21066 {
21067 return; //eSHOOTFBALL are alive but enemies from the list
21068 } //are not. Defer to HeroClass::checkspecial().
21069
21070 77 int32_t Item=scr->item;
21071
21072 77 state.item_state = ScreenItemState::None;
21073
21074
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
21075 {
21076 154 auto [x, y] = translate_screen_coordinates_to_world(screen);
21077 218 additem(x,y,Item,ipENEMY+ipONETIME+ipBIGRANGE
21078
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 13 times.
77 + (((scr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21079 );
21080 77 ((item*)items.spr(items.Count() - 1))->screen_spawned = screen;
21081 77 state.item_state = ScreenItemState::CarriedByEnemy;
21082 77 }
21083 else
21084 {
21085 return;
21086 }
21087 77 }
21088
21089
2/2
✓ Branch 0 taken 46044 times.
✓ Branch 1 taken 36535 times.
82579 for(int32_t i=0; i<items.Count(); i++)
21090 {
21091
4/4
✓ Branch 0 taken 42433 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 5898 times.
✓ Branch 3 taken 36535 times.
46044 if(((item*)items.spr(i))->pickup&ipENEMY && ((item*)items.spr(i))->screen_spawned == screen)
21092 {
21093
2/2
✓ Branch 0 taken 22240 times.
✓ Branch 1 taken 14295 times.
36535 if(get_qr(qr_HIDECARRIEDITEMS))
21094 {
21095 22240 items.spr(i)->x = -128; // Awfully inelegant, innit?
21096 22240 items.spr(i)->y = -128;
21097 22240 }
21098
2/4
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14295 times.
14295 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21099 {
21100
1/2
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
14295 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21101 {
21102 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21103 {
21104 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21105 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21106 }
21107 else
21108 {
21109 if(guys.spr(guycarryingitem)->extend >= 3)
21110 {
21111 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21112 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21113 }
21114 else
21115 {
21116 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21117 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21118 }
21119 }
21120 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21121 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21122 }
21123 else
21124 {
21125 14295 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21126 14295 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21127 14295 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21128 }
21129 14295 }
21130 36535 }
21131 46044 }
21132 14697000 }
21133
21134 14309072 void roaming_item()
21135 {
21136 29006072 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
21137 14697000 roaming_item(scr);
21138 14697000 });
21139 14309072 }
21140
21141 bool enemy::IsBigAnim()
21142 {
21143 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21144 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21145 || anim == a4FRM8DIRB);
21146 }
21147 2418527 int32_t enemy::getFlashingCSet()
21148 {
21149 //Special cset for the dying sprite
21150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2418527 times.
2418527 if(dying)
21151 {
21152 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21153 return wpnsbuf[spr_death].csets & 15;
21154 else
21155 return (((clk2 + 5) >> 1) & 3) + 6;
21156 }
21157
21158 //Normal cset
21159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2418527 times.
2418527 if (hclk <= 0)
21160 {
21161 //Special cset for the flashing animation
21162 if (flags & guy_flashing)
21163 return (frame & 3) + 6;
21164 return cs;
21165 }
21166
21167 //Hurt animations
21168
2/2
✓ Branch 0 taken 3564 times.
✓ Branch 1 taken 2414963 times.
2418527 if(family==eeGANON)
21169 3564 return (((hclk-1)>>1)&3)+6;
21170
4/4
✓ Branch 0 taken 2245020 times.
✓ Branch 1 taken 169943 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1757882 times.
2414963 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21171 1757882 return (((hclk-1)>>1)&3)+6;
21172
21173 657081 return cs;
21174 2418527 }
21175
21176 81972153 bool enemy::is_hitflickerframe(bool olddrawing)
21177 {
21178
6/6
✓ Branch 0 taken 81946325 times.
✓ Branch 1 taken 25828 times.
✓ Branch 2 taken 3972505 times.
✓ Branch 3 taken 77973820 times.
✓ Branch 4 taken 3199814 times.
✓ Branch 5 taken 772691 times.
81972153 if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21179 81199462 return false;
21180
21181
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21182 return false;
21183
21184 772691 int32_t fr = game->get_spriteflickerspeed();
21185
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21186 return true;
21187 772691 return frame % (fr * 2) < fr;
21188 81972153 }
21189
21190 const char *old_guy_string[OLDMAXGUYS] =
21191 {
21192 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21193 // 020
21194 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21195 // 025
21196 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21197 // 030
21198 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21199 // 035
21200 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21201 // 040
21202 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21203 // 045
21204 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21205 // 050
21206 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21207 // 055
21208 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21209 // 060
21210 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21211 // 065
21212 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21213 // 070
21214 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21215 // 075
21216 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21217 // 080
21218 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21219 // 085
21220 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21221 // 090
21222 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21223 // 095
21224 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21225 // 100
21226 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21227 // 105
21228 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21229 // 110
21230 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21231 // 115
21232 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21233 // 120
21234 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21235 // 125
21236 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21237 // 130
21238 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21239 // 135
21240 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21241 // 140
21242 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21243 // 145
21244 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21245 // 150
21246 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21247 // 155
21248 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21249 // 160
21250 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21251 // 165
21252 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21253 // 170
21254 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21255 // 175
21256 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21257 };
21258
21259 15687886 int32_t enemy::get_dmisc(byte index)
21260 {
21261
20/33
✓ Branch 0 taken 14611 times.
✓ Branch 1 taken 15885 times.
✓ Branch 2 taken 3236 times.
✓ Branch 3 taken 7390 times.
✓ Branch 4 taken 2144 times.
✓ Branch 5 taken 1794 times.
✓ Branch 6 taken 1051 times.
✓ Branch 7 taken 250 times.
✓ Branch 8 taken 1852 times.
✓ Branch 9 taken 1822 times.
✓ Branch 10 taken 7793452 times.
✓ Branch 11 taken 7597384 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 40 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 216 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 884 times.
✓ Branch 25 taken 1120 times.
✓ Branch 26 taken 331 times.
✓ Branch 27 taken 238061 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 6055 times.
✗ Branch 32 not taken.
15687886 switch (index)
21262 {
21263 14611 case 0: return dmisc1;
21264 15885 case 1: return dmisc2;
21265 3236 case 2: return dmisc3;
21266 7390 case 3: return dmisc4;
21267 2144 case 4: return dmisc5;
21268 1794 case 5: return dmisc6;
21269 1051 case 6: return dmisc7;
21270 250 case 7: return dmisc8;
21271 1852 case 8: return dmisc9;
21272 1822 case 9: return dmisc10;
21273 7793452 case 10: return dmisc11;
21274 7597384 case 11: return dmisc12;
21275 case 12: return dmisc13;
21276 308 case 13: return dmisc14;
21277 case 14: return dmisc15;
21278 40 case 15: return dmisc16;
21279 case 16: return dmisc17;
21280 216 case 17: return dmisc18;
21281 case 18: return dmisc19;
21282 case 19: return dmisc20;
21283 case 20: return dmisc21;
21284 case 21: return dmisc22;
21285 case 22: return dmisc23;
21286 case 23: return dmisc24;
21287 884 case 24: return dmisc25;
21288 1120 case 25: return dmisc26;
21289 331 case 26: return dmisc27;
21290 238061 case 27: return dmisc28;
21291 case 28: return dmisc29;
21292 case 29: return dmisc30;
21293 case 30: return dmisc31;
21294 6055 case 31: return dmisc32;
21295 }
21296
21297 return 0;
21298 15687886 }
21299
21300 312 void enemy::set_dmisc(byte index, int32_t value)
21301 {
21302
3/33
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 24 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 284 times.
✗ Branch 32 not taken.
312 switch (index)
21303 {
21304 case 0: dmisc1 = value; break;
21305 case 1: dmisc2 = value; break;
21306 case 2: dmisc3 = value; break;
21307 case 3: dmisc4 = value; break;
21308 case 4: dmisc5 = value; break;
21309 case 5: dmisc6 = value; break;
21310 case 6: dmisc7 = value; break;
21311 case 7: dmisc8 = value; break;
21312 case 8: dmisc9 = value; break;
21313 case 9: dmisc10 = value; break;
21314 case 10: dmisc11 = value; break;
21315 case 11: dmisc12 = value; break;
21316 case 12: dmisc13 = value; break;
21317 case 13: dmisc14 = value; break;
21318 case 14: dmisc15 = value; break;
21319 case 15: dmisc16 = value; break;
21320 case 16: dmisc17 = value; break;
21321 case 17: dmisc18 = value; break;
21322 case 18: dmisc19 = value; break;
21323 case 19: dmisc20 = value; break;
21324 case 20: dmisc21 = value; break;
21325 case 21: dmisc22 = value; break;
21326 case 22: dmisc23 = value; break;
21327 case 23: dmisc24 = value; break;
21328 case 24: dmisc25 = value; break;
21329 case 25: dmisc26 = value; break;
21330 4 case 26: dmisc27 = value; break;
21331 24 case 27: dmisc28 = value; break;
21332 case 28: dmisc28 = value; break;
21333 case 29: dmisc30 = value; break;
21334 case 30: dmisc31 = value; break;
21335 284 case 31: dmisc32 = value; break;
21336 }
21337 312 }
21338